Closed ZYinMD closed 4 years ago
it has nothing to do with the cleverness, it's just practice and experience
since you are already able to run mykit
, then you'd be glad to see a sub-command iwara.dl
in the help doc
mykit iwara.dl
did nothing more than just importing and calling that youtube_dl_main_x_iwara()
func
forgot to tell you this yesterday since i thought that function is already very very easy to use
anyway, you just mykit iwara.dl -- <put those youtube-dl arguments here>
have a good day
Am I doing it right?
#mykit iwrdl -h
usage: mykit.py iwara.dl [-h] [argv [argv ...]]
modified youtube-dl for iwara.tv (fixing issue of missing uploader)
positional arguments:
argv argument(s) propagated to youtube-dl, better put a -- before it
optional arguments:
-h, --help show this help message and exit
better put a -- before it
put a --
after the sub-command and before the remaining arguments
--
means the end of options, so anything after --
won't be handled by mykit
but all propagated to youtube_dl_main_x_iwara()
Thanks! I got it to work! However, there seems to an issue when using --config-location
.
--config-location
is a very nice way to store all my flags in a file, for example:
# iwara-settings.conf
# where to save
--output 'path/to/download-location/%(uploader)s - %(title)s.%(ext)s'
# all urls to be downloaded
--batch-file path/to/urls.txt
# skip videos that have been downloaded before
--download-archive path/to/already-downloaded.txt
# continue if error occurs on one video
--ignore-errors
# embed metadata into mp4 files
--add-metadata
Then I can do $ youtube-dl --config-location path/to/iwara-settings.conf
However, if I do $ mykit iwrdl -- --config-location path/to/iwara-settings.conf
, it doesn't seem to work.
Except --config-location
, all other flags seem to work well if directly passed in the CLI (even when I pass no url and use --batch-file
instead of an url). By the way if you use --batch-file
, you'll no longer need run.from.lines
.
@ZYinMD that err msg came from youtube-dl itself
>youtube-dl.exe --config-location r:t.conf
Usage: youtube-dl [OPTIONS] URL [URL...]
youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.
at least one URL is a must given arg for youtube-dl
Yes, but if you compare the two commands in the screenshot, they're passing exactly the same arguments, and the first one was successful. Maybe the arguments somehow didn't get passed to youtube-dl in the second case?
In your case with r:t.conf
, you need to put a --batch-file
inside t.conf
. If you did, you should be able to use youtube-dl.exe without directly providing a url in the CLI, for instance:
# r:t.conf
--batch-file r:urls.txt
# r:urls.txt
https://www.iwara.tv/videos/9rqootnagjtz93kyr
then
>youtube-dl.exe --config-location r:t.conf
then disuse mykit.py
, write your own .py
file to use:
from mylib.iwara import youtube_dl_main_x_iwara
youtube_dl_main_x_iwara()
~i use the python standard lib argparse
to parse arguments and make mykit.py
, while youtube-dl
do the parsing job in a different way -- more complicated, more sophisticated, more custom, and more self-made. so your speculation may be right, the --config-location
may be parsed and processed in a special way, which cannot be fully propagated to the underlying function...~
fixed, not very hard to find the reason
youtube-dl.main()
function depends on optparse
lib to parse options, but it build a lot of sophisticated structure to do it in a very complicate and powerful way
but that's not the reason why things goes wrong for mykit
youtube_dl.main()
func has an optional argument, which if been given, the underlying _real_main()
func would treat it as "override arguments" and process them in a different way. didn't dig in to see how "different" it would be, but, anyway if the tailing arguments are not put into main()
func then they wouldn't be treated as "override arguments" and thus won't be processed in that "different" way
the only thing need to do is to modify the "system arguments" sys.argv
into those tailing arguments which are already parsed by mykit
, and call youtube_dl_main_x_iwara()
with no argument
a commit is pushed to this repo and you can pull and try it
报告! 成功!!!
虽然你所描述的一顿操作我基本看不懂, 但还是要给你10086个赞!!
Tested and can verify it works like a charm! Thanks so much! Hope this will help people in the future who search for youtube-dl iwara
and find that issue and then find this issue.
Closing.
Hi, I found this repo when reading the discussion at ytdl-org/youtube-dl#24237 . I was able to successfully use
mykit cburl iwara
to extract urls from clipboard (thumbs up!), but as someone who doesn't know python at all, I wasn't smart enough to figure out how to run theyoutube_dl_main_x_iwara
function.So, the way I've always been using
youtube-dl
is by runningyoutube-dl --option1 --option2 --etc-etc
in CLI. Can I use your monkey patch version in a similar fashion? How do I do it? Thanks so much!