Skip to content
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

[Youtube] flat-playlist extractor correction for playlist results and partial added duration #25848

Closed
Crypto90 opened this issue Jun 30, 2020 · 4 comments
Labels

Comments

@Crypto90
Copy link

@Crypto90 Crypto90 commented Jun 30, 2020

Checklist

  • I'm reporting a feature request
  • I've verified that I'm running youtube-dl version 2020.06.16.1
  • I've searched the bugtracker for similar feature requests including closed ones

Description

WRITE DESCRIPTION HERE

In the uploaded youtube.py.txt file I have made some changes for the youtube.py extractor to add the new feature to get correct results when searching youtube playlists.
The changed code checks if the /wach?v= url also contains list=, if so, also the playlist id gets extracted.
The printed result will also be checked for the video id length (11 = video id, larger than 11 = playlist id)

RESULTS searching for playlists:

python youtube-dl -4 --no-warnings --no-check-certificate "ytsearch10:nightcore,playlist" --dump-json --playlist-start 1 --playlist-end 10 --flat-playlist
{"url": "https://www.youtube.com/playlist?list=PL0wqt_um4x0bsdViTJBmnl6KGMoSqxfZy", "_type": "url", "ie_key": "YoutubePlaylist", "id": "PL0wqt_um4x0bsdViTJBmnl6KGMoSqxfZy", "title": "Most Viewed Nightcore"}
{"url": "https://www.youtube.com/playlist?list=PLckeMyCaCCIN_JU1V4oADW50DlGOREoLj", "_type": "url", "ie_key": "YoutubePlaylist", "id": "PLckeMyCaCCIN_JU1V4oADW50DlGOREoLj", "title": "Ultimatum [Nightcore playlist]"}
{"url": "https://www.youtube.com/playlist?list=PLyTi20i8cwsPyiwvjei-K6F04Rzm0uRpT", "_type": "url", "ie_key": "YoutubePlaylist", "id": "PLyTi20i8cwsPyiwvjei-K6F04Rzm0uRpT", "title": "Old School Nightcore"}
{"url": "https://www.youtube.com/playlist?list=PLMk3t51Sma9Ez2tjSzks3N06cwckoz2-m", "_type": "url", "ie_key": "YoutubePlaylist", "id": "PLMk3t51Sma9Ez2tjSzks3N06cwckoz2-m", "title": "NightCore Emo"}
{"url": "https://www.youtube.com/playlist?list=PLT5Nlf1NmV4Mqfha4j1YuCTk0GCL20bdN", "_type": "url", "ie_key": "YoutubePlaylist", "id": "PLT5Nlf1NmV4Mqfha4j1YuCTk0GCL20bdN", "title": "BoxBox Nightcore COMPLETE"}
{"url": "https://www.youtube.com/playlist?list=PLOTApxgUwuOKLxLhKAs8IVY7gPO7jBzD2", "_type": "url", "ie_key": "YoutubePlaylist", "id": "PLOTApxgUwuOKLxLhKAs8IVY7gPO7jBzD2", "title": "Nightcore - Gacha Songs"}
{"url": "https://www.youtube.com/playlist?list=PL_2-M0cHcLO4PYOoiyq0PxOeHqGlhlnmQ", "_type": "url", "ie_key": "YoutubePlaylist", "id": "PL_2-M0cHcLO4PYOoiyq0PxOeHqGlhlnmQ", "title": "The Ultimate Nightcore Playlist"}
{"url": "https://www.youtube.com/playlist?list=PLT2qINU1sbUh0ECl94rEWddz9dLA10t6H", "_type": "url", "ie_key": "YoutubePlaylist", "id": "PLT2qINU1sbUh0ECl94rEWddz9dLA10t6H", "title": "Nightcore Playlist"}
{"url": "https://www.youtube.com/playlist?list=PLM6aAK5yk-8KWSSW8zJCBkNCP_Kvom6S5", "_type": "url", "ie_key": "YoutubePlaylist", "id": "PLM6aAK5yk-8KWSSW8zJCBkNCP_Kvom6S5", "title": "Sexual Nightcore Songs"}
{"url": "https://www.youtube.com/playlist?list=PLNNA4xoj8rtiyGCKKW-ZJAgE07puDN9wb", "_type": "url", "ie_key": "YoutubePlaylist", "id": "PLNNA4xoj8rtiyGCKKW-ZJAgE07puDN9wb", "title": "Upbeat Nightcore"}

RESULTS searching for single videos:

python youtube-dl -4 --no-warnings --no-check-certificate "ytsearch10:nightcore,video" --dump-json --playlist-start 1 --playlist-end 10 --flat-playlist
{"url": "fSlOHZXhcMk", "_type": "url", "ie_key": "Youtube", "id": "fSlOHZXhcMk", "title": "Nightcore - Dracula - (Lyrics)"}
{"url": "0NSCkfyA6uY", "_type": "url", "ie_key": "Youtube", "id": "0NSCkfyA6uY", "title": "Nightcore - Stick Together"}
{"url": "nuTsXUYUavw", "_type": "url", "ie_key": "Youtube", "id": "nuTsXUYUavw", "title": "Nightcore - What You Made Me - (Lyrics)"}
{"url": "E3FfwK81OsU", "_type": "url", "ie_key": "Youtube", "id": "E3FfwK81OsU", "title": "Nightcore - Savage Love - (Lyrics)"}
{"url": "hjGZLnja1o8", "_type": "url", "ie_key": "Youtube", "id": "hjGZLnja1o8", "title": "Nightcore - Rockefeller Street"}
{"url": "9xG5aPvrS-k", "_type": "url", "ie_key": "Youtube", "id": "9xG5aPvrS-k", "title": "Nightcore - No Friends (Lyrics)"}
{"url": "cvaIgq5j2Q8", "_type": "url", "ie_key": "Youtube", "id": "cvaIgq5j2Q8", "title": "Nightcore - Angel With A Shotgun"}
{"url": "Zm1vKR2hNyc", "_type": "url", "ie_key": "Youtube", "id": "Zm1vKR2hNyc", "title": "Nightcore - Odds Are - (Lyrics)"}
{"url": "z6lJlIp9Y50", "_type": "url", "ie_key": "Youtube", "id": "z6lJlIp9Y50", "title": "Nightcore - Tick Tick Tick - (Lyrics)"}
{"url": "cyW2ajAVyfA", "_type": "url", "ie_key": "Youtube", "id": "cyW2ajAVyfA", "title": "Nightcore - Take A Hint"}

I have also changed the video regex to fetch the video durations, which already works, but at line 327

if len(video_id) == 11:
                #youtube video id found
                yield self.url_result(video_id, 'Youtube', video_id, video_title)

the self.url_result(...) function errors if I change it to:

if len(video_id) == 11:
                #youtube video id found
                yield self.url_result(video_id, 'Youtube', video_id, video_title, video_duration)

That it expects 4 arguments and not 5. I looked at the code where the self.url_result(...) function is defined but I could not find it. Maybe someone can help out here for this last step.

Other topic relations:
#25720
#16627
#25652

youtube.py.txt

@Crypto90 Crypto90 added the request label Jun 30, 2020
@Crypto90
Copy link
Author

@Crypto90 Crypto90 commented Jun 30, 2020

I also want to fetch the videos counter of each youtube playlist result, but I did not get the regex working for that.
The videos count information is there. But to make it simple, I will split the playlists video counter changes with this request.
The html code for each playlist videos counter looks like this:

<span class="formatted-video-count-label"><b>352</b> videos</span>
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jun 30, 2020

File a PR.

@dstftw dstftw closed this Jun 30, 2020
@Crypto90
Copy link
Author

@Crypto90 Crypto90 commented Jun 30, 2020

@dstftw I tried, I never have done a pull request here. If I click the "New pull request" button, I can only compare branches.
Or is it a simple commit which get transformed to a pull request?

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jun 30, 2020

Read developer instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.