Skip to content

Commit

Permalink
[vvvvid] fix season metadata extraction(ytdl-org#18130)
Browse files Browse the repository at this point in the history
  • Loading branch information
remitamine authored and ThirumalaiK committed Jan 28, 2021
1 parent 651f736 commit dd851f2
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions youtube_dl/extractor/vvvvid.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class VVVVIDIE(InfoExtractor):
'duration': 239,
'series': '"Perché dovrei guardarlo?" di Dario Moccia',
'season_id': '437',
'season_number': 1,
'episode': 'Ping Pong',
'episode_number': 1,
'episode_id': '3334',
Expand Down Expand Up @@ -75,7 +74,6 @@ def _download_info(self, show_id, path, video_id, fatal=True):
def _extract_common_video_info(self, video_data):
return {
'thumbnail': video_data.get('thumbnail'),
'episode_number': int_or_none(video_data.get('number')),
'episode_id': str_or_none(video_data.get('id')),
}

Expand Down Expand Up @@ -145,6 +143,17 @@ def f(m):

return d

info = {}

def metadata_from_url(r_url):
if not info and r_url:
mobj = re.search(r'_(?:S(\d+))?Ep(\d+)', r_url)
if mobj:
info['episode_number'] = int(mobj.group(2))
season_number = mobj.group(1)
if season_number:
info['season_number'] = int(season_number)

for quality in ('_sd', ''):
embed_code = video_data.get('embed_info' + quality)
if not embed_code:
Expand All @@ -166,17 +175,19 @@ def f(m):
else:
formats.extend(self._extract_wowza_formats(
'http://sb.top-ix.org/videomg/_definst_/mp4:%s/playlist.m3u8' % embed_code, video_id))
metadata_from_url(embed_code)

self._sort_formats(formats)

info = self._extract_common_video_info(video_data)
metadata_from_url(video_data.get('thumbnail'))
info.update(self._extract_common_video_info(video_data))
info.update({
'id': video_id,
'title': title,
'formats': formats,
'duration': int_or_none(video_data.get('length')),
'series': video_data.get('show_title'),
'season_id': season_id,
'season_number': video_data.get('season_number'),
'episode': title,
'view_count': int_or_none(video_data.get('views')),
'like_count': int_or_none(video_data.get('video_likes')),
Expand Down Expand Up @@ -211,7 +222,6 @@ def _real_extract(self, url):

entries = []
for season in (seasons or []):
season_number = int_or_none(season.get('number'))
episodes = season.get('episodes') or []
for episode in episodes:
if episode.get('playable') is False:
Expand All @@ -227,7 +237,6 @@ def _real_extract(self, url):
'url': '/'.join([base_url, season_id, video_id]),
'title': episode.get('title'),
'description': episode.get('description'),
'season_number': season_number,
'season_id': season_id,
})
entries.append(info)
Expand Down

0 comments on commit dd851f2

Please sign in to comment.