Skip to content

Commit

Permalink
[mtv] fix mgid extraction(closes ytdl-org#26841)
Browse files Browse the repository at this point in the history
  • Loading branch information
remitamine authored and ThirumalaiK committed Jan 28, 2021
1 parent 039e715 commit dac56cf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions youtube_dl/extractor/mtv.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,18 @@ class MTVIE(MTVServicesInfoExtractor):
'only_matching': True,
}]

@staticmethod
def extract_child_with_type(parent, t):
children = parent['children']
return next(c for c in children if c.get('type') == t)

def _extract_mgid(self, webpage):
data = self._parse_json(self._search_regex(
r'__DATA__\s*=\s*({.+?});', webpage, 'data'), None)
main_container = self.extract_child_with_type(data, 'MainContainer')
video_player = self.extract_child_with_type(main_container, 'VideoPlayer')
return video_player['props']['media']['video']['config']['uri']


class MTVJapanIE(MTVServicesInfoExtractor):
IE_NAME = 'mtvjapan'
Expand Down

0 comments on commit dac56cf

Please sign in to comment.