Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Request to add playlist downloads for ytsearch query. #16627
Comments
|
Any plans to get this done? I require this too. I will also look into the code, what needs to get changed. |
|
Go to the extractor for youtube, (youtube_dl/extractor/youtube.py) and in the function that uses 'ytsearch' as its _Search_Key you have to regex the url passed to it and if its a playlist you would have to then call the module that downloads playlists or copy that functionality over. I was hoping someone with knowledge of the code could do this and forgot about it. Hope this was helpful Respectfully, |
|
Thanks, this was helpful, I will look at the code to get it changed and add a patch for it. |
|
As far as I can see, this regular expression:
in youtube.py which gets used here:
at the extract_videos_from_page function. This regular expression checks only for the /watch?"v=XXXXXX" part and ignores the "&list=YYYYYYYYYYYYYYYYYYYY" from the href urls. Im not too incorporated with the whole youtube-dl code to change something without probably breaking an other function, so maybe someone else which is more worked in in the code should look at this too. |
|
Got it working:
Result:
I changed the regex to also search for the list=XXXXXXX value, if the href also has the list= attribute, the video_id get replaced with the found playlist_id. Im currently working on the regex to fetch more informations like the video durations and if we find a playlist the video count from the list which is requested here (which I also need): This also fixes the issue of not always resulting titles for playlists, as far as I can see. |
|
Update: Video duration extraction is already implemented too, but the
part needs a new argument to pass the duration over. CURRENT CODE (youtube.py):
Current results for PLAYLISTS:
Current results for NORMAL VIDEOS:
Pending todo:
|
Please follow the guide below
xinto all the boxes [ ] relevant to your issue (like this:[x])Make sure you are using the latest version: run
youtube-dl --versionand ensure your version is 2018.06.02. If it's not, read this FAQ entry and update. Issues with outdated version will be rejected.Before submitting an issue make sure you have:
What is the purpose of your issue?
When I query as follows:
$ youtube-dl ytsearch:"funny dogs, playlist"
all results of this query will be playlists. youtube-dl will download the first video in the playlist and not the others. I would ask that there be an option to download the entire playlist as there is already an implementation to download playlists in youtube-dl and all it would need is an 'if' statement to check if the URL of the first video in a query was of a playlist and if so you would just regex the playlist link from the URL.
Example:
The first video in the query "funny dogs, playlist" is this URL.
https://www.youtube.com/watch?v=wRqft4Rb4UU&list=PLGTScjq3z9bjBXGEUADkq27kmtfO-s25G
And the playlist link is:
https://www.youtube.com/playlist?list=PLGTScjq3z9bjBXGEUADkq27kmtfO-s25G
just regex out the video id and add 'playlist' where 'watch' is.
Therefore, if the query is of a playlist then youtube-dl could either prompt to download or ytsearch could have a flag to download playlists or even just printing the URL and saying that it is a playlist would be helpful.
I have looked at the code and seen that the pieces are there already there. They just need to be linked.
Respectfully,
Trevor