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

returning title on youtube playlists #15787

Closed
quekky opened this issue Mar 7, 2018 · 0 comments
Closed

returning title on youtube playlists #15787

quekky opened this issue Mar 7, 2018 · 0 comments

Comments

@quekky
Copy link

@quekky quekky commented Mar 7, 2018

I try to get the list of playlists from a user playlist page. It works however there is only URL returned (no title)

eg,

ydl = YoutubeDL({'quiet':False,'extract_flat':True,'dump_single_json':True})
res = ydl.extract_info('https://www.youtube.com/user/CNETTV/playlists')
print(rest)

the returned result only contains url

(same for cli)

# youtube-dl.exe -j --flat-playlist https://www.youtube.com/user/CNETTV/playlists
{"_type": "url", "url": "https://www.youtube.com/playlist?list=PLAl4aZK3mRv1ydJm1nXwZ9Toz_mSlOesg", "ie_key": "YoutubePlaylist"}
{"_type": "url", "url": "https://www.youtube.com/playlist?list=PL29BED3BCF9244BA0", "ie_key": "YoutubePlaylist"}
{"_type": "url", "url": "https://www.youtube.com/playlist?list=PLAl4aZK3mRv1c8dKfLFX2W5diuo8qHwIn", "ie_key": "YoutubePlaylist"}
{"_type": "url", "url": "https://www.youtube.com/playlist?list=PLAl4aZK3mRv3IcNpOPB93hLv4I6eTjL49", "ie_key": "YoutubePlaylist"}
....

So I looked into the source code and edited youtube.py to return title:

class YoutubePlaylistsBaseInfoExtractor(YoutubeEntryListBaseInfoExtractor):
    def _process_page(self, content):
        for playlist_id, video_title in orderedSet(re.findall(
                r'<h3[^>]+class="[^"]*yt-lockup-title[^"]*"[^>]*><a[^>]+href="/?playlist\?list=([0-9A-Za-z-_]{10,})"(?:[^>]+>(?P<title>[^<]+))?',
                content)):
            video_title = unescapeHTML(video_title)
            if video_title:
                video_title = video_title.strip()
            yield self.url_result(
                'https://www.youtube.com/playlist?list=%s' % playlist_id, 'YoutubePlaylist', video_title=video_title)

now it returns title of the playlist

{"_type": "url", "url": "https://www.youtube.com/playlist?list=PLAl4aZK3mRv1ydJm1nXwZ9Toz_mSlOesg", "ie_key": "YoutubePlaylist", "title": "CNET special features"}
{"_type": "url", "url": "https://www.youtube.com/playlist?list=PL29BED3BCF9244BA0", "ie_key": "YoutubePlaylist", "title": "CNET First Look videos "}
@dstftw dstftw closed this Mar 7, 2018
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.