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] fixed --flat-playlist always showing uploader as none #28045

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions test/test_youtube_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from youtube_dl.extractor import (
YoutubePlaylistIE,
YoutubeTabIE,
YoutubeIE,
)

Expand Down Expand Up @@ -66,6 +67,16 @@ def test_youtube_flat_playlist_titles(self):
for entry in result['entries']:
self.assertTrue(entry.get('title'))

def test_youtube_flat_playlist_uploaders(self):
dl = FakeYDL()
dl.params['extract_flat'] = True
ie = YoutubeTabIE(dl)
result = ie.extract('https://www.youtube.com/playlist?list=PL2zzFmCbIz4fshCLrvopue-wDeKQ5ERKO')
self.assertIsPlaylist(result)
for entry in result['entries']:
if entry['title'] not in ('[Deleted video]', '[Private video]'):
self.assertTrue(entry.get('uploader'))
Comment on lines +70 to +78
Copy link
Collaborator

@dstftw dstftw Feb 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test should be added to _TESTS of extractor class. Use one of the youtube-dl's test playlists for testing, e.g. https://www.youtube.com/playlist?list=PL4lCao7KL_QFVb7Iudeipvc2BCavECqzc.



if __name__ == '__main__':
unittest.main()
4 changes: 3 additions & 1 deletion youtube_dl/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ def _extract_video(self, renderer):
r'^([\d,]+)', re.sub(r'\s', '', view_count_text),
'view count', default=None))
uploader = try_get(
renderer, lambda x: x['ownerText']['runs'][0]['text'], compat_str)
PrinceOfPuppers marked this conversation as resolved.
Show resolved Hide resolved
renderer,
(lambda x: x['ownerText']['runs'][0]['text'],
lambda x: x['shortBylineText']['runs'][0]['text']), compat_str)
return {
'_type': 'url_transparent',
'ie_key': YoutubeIE.ie_key(),
Expand Down