-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/extra #79
Feature/extra #79
Conversation
Added another fix where using |
And finally, I made a first draft of downloading episodes from the Extra section using |
Woohoo, thanks! I won't have time to look into it tonight, maybe tomorrow night. If somebody else wants to take a look, go ahead. |
So I was able to make Code is a little messy, but it works. Of note: you will need to delete your .toutv-cache for new emissions & episodes to be loaded from the API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at an login conversation from an Android phone with mitmproxy, it matches pretty much what you added. LGTM.
Err, I wanted to comment on the first commit. Is there any way to leave a comment on a particular commit? |
Pushed your xdg/cache folder commit to master, since it's unrelated and helpful in any case. |
Instead of requiring the user to enter two URLs (which is a bit tedious), could we solve the problem by having our client do a bit more work? For example, the HTML of an episode contains the show name at least:
Perhaps we could do another request to look up the show/emission id? |
Actually, given that an episode url looks like this:
We could simply deduce the show URL by keeping the first URL component after the domain... or use the info mentioned in the previous comment and append it to |
@simark To comment on any commit part of a PR, simply click the commit that appears in the PR, and comment on specific lines there, or you can go in the |
Could you rebase the current Feature/extra branch on top of the current master, to make this PR easier to read? It should then automatically adjust to only show the changes I made (if not, I'll manually update my branch). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As suggested by @simark, since the episode URLs look like http://ici.tou.tv/[emission-name]/[episode-name], we could allow using a single URL, and deducing the emission URL.
Another suggestion: allow both an episode URL and an emission URL, when using --url
.
Ok, I've rebased |
Excellent. Much better now; easier to review. So I added two commits which allows a user to specify an emission by name or URL for |
Ah good idea about not having to use |
This makes argparse handle automatically the case where the (sub-)command is omitted. For example, using just "toutv" would show the help, but using "toutv --verbose" would result in an exception: Traceback (most recent call last): File "/home/simark/src/pytoutv-env/bin/toutv", line 9, in <module> load_entry_point('pytoutv==2.3.1', 'console_scripts', 'toutv')() File "/home/simark/src/pytoutv/toutvcli/app.py", line 672, in run return app.run() File "/home/simark/src/pytoutv/toutvcli/app.py", line 91, in run if args.build_client: AttributeError: 'Namespace' object has no attribute 'build_client' As a result, we don't return the exit code 10 when bad arguments are given. Signed-off-by: Simon Marchi <[email protected]>
Rename _toutvclient to _toutv_client. Also, initialize it in __init__ to silence PyCharms warning.
... to silence PyCharms warning.
PyCharms complains that toutv.exceptions is not imported. I am not sure if it's necessary or not, but it doesn't hurt to have it.
@gboudreau, is it possible that the command
|
Indeed. Fixed. |
@@ -222,6 +222,8 @@ def _build_argparser(self): | |||
pf.add_argument('-q', '--quality', action='store', | |||
default=App.QUALITY_AVG, choices=quality_choices, | |||
help='Video quality (default: {})'.format(App.QUALITY_AVG)) | |||
pf.add_argument('-v', '--verbose', action='store_true', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to have a --verbose
for each command? If we only have one in the top-level parser, it forces the user to put the -v/--verbose
between toutv
and the subcommand, but is it a problem? It's a flag that affects the whole program, not just the subcommand, so I think it would make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know that would work. Will remove all --verbose
param handlers I added to pf/pi/pl. Thanks.
I don't see any reason why we have to handle the NoMatchExceptions in different places. It will give the same result if we catch it along with the other exceptions, at the top-level (the App.run method).
…g both emission and episode URLs; the emission info is not found in the episode HTML any more...
…mmand: toutv fetch --url [emission_url] [episode_url] eg. toutv fetch -q MAX --url 'http://ici.tou.tv/le-show-cache-2' 'http://ici.tou.tv/le-show-cache-2/S2014E01' We still can't load the episode or emission information for Extras, but I think most people just want `fetch` to work. They can find the URLs to use by browsing ici.tou.tv, and then download the episodes they want from the command line.
…rs; it's now possible to `list`, `search`, `info` and `fetch` those emissions/episodes. Examples: toutv list --all # Now returns 3,350 emissions; returned 1,525 before toutv search|info|list "Le show caché 2" toutv info "Le show caché 2" S2014E01 toutv info "Le show caché 2" 2425154669 toutv info --url 'http://ici.tou.tv/le-show-cache-2' 'http://ici.tou.tv/le-show-cache-2/S2014E01' toutv fetch "Le show caché 2" toutv fetch "Le show caché 2" S2014E02
…GET /presentation/...
… instead; no need to specify --url anymore. Also don't need two URLs anymore; only specifying the episode URL is enough. Examples: - toutv fetch|info 'Le show caché 2' - toutv fetch|info http://ici.tou.tv/le-show-cache-2 - toutv fetch|info 'Le show caché 2' 'S2014E02' - toutv fetch|info http://ici.tou.tv/le-show-cache-2/S2014E02 - toutv list 'Le show caché 2' - toutv list http://ici.tou.tv/le-show-cache-2
@gboudreau, I rebased your branch and added one commit to allow specifying only an URL to the episode (to fetch and info). Basically, doing It is in my repo: https://github.com/simark/pytoutv/tree/feature/extra |
This patch makes it possible to fetch, list or show the info simply by specifying the URL to the resource (show or episode). Therefore, it should now be possible to fetch using one of the following forms: - toutv fetch <show> - toutv fetch <show> <episode> - toutv fetch <show-url> - toutv fetch <episode> <url> Same for info. We suggested some time ago to try to migrate from "emission" to "show", since it's a bit silly (although cute) to use franglais. I am converting the areas I touch to use that name. I removed the current test, since it's not very useful, and added a test for the show/episode argument parsing. It will be stable, since it doesn't depend on external factors.
Failure: |
`toutv search` returned episodes as shows because of this!
…n all the information needed to be able to download them (namely, the PID is missing). This commit adds the notion of 'short_version' for episodes: the short version of an episode is enough to display it to the end-user, but not enough to download it. So we either load the short version (which can be cached) or the full version, when needed; for example, for `toutv fetch`.
…sodes are returned by `GET GetEpisodesForEmission`; using `GET /presentation/[show_url]` first fixed that.
Above issue fixed with those last few commits. |
@gboudreau, I have rebased the branch and pushed it as master. At least now that it's in master, we'll be able to do fixes in more targetted PRs, instead of doing everything in this one. Thanks a lot! |
Rebased on latest master (83aebdb) and fixed login command that didn't work anymore.
Also fixed an issue where it would use the current folder instead of
$HOME/.cache/toutv/
folder for cache on Mac.