From: Philipp Hagemeister Date: Sat, 19 Apr 2014 17:55:53 +0000 (+0200) Subject: [steam] Simplify X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=7f9c31df880b02ef1746e2c73f4c1e5aee3da06a;p=youtube-dl [steam] Simplify --- diff --git a/youtube_dl/extractor/steam.py b/youtube_dl/extractor/steam.py index b3cbbfd77..89ac52e66 100644 --- a/youtube_dl/extractor/steam.py +++ b/youtube_dl/extractor/steam.py @@ -10,7 +10,7 @@ from ..utils import ( class SteamIE(InfoExtractor): - _VALID_URL = r"""http://store\.steampowered\.com/ + _VALID_URL = r"""(?x)http://store\.steampowered\.com/ (agecheck/)? (?Pvideo|app)/ #If the page is only for videos or for a game (?P\d+)/? @@ -39,15 +39,12 @@ class SteamIE(InfoExtractor): 'playlist_index': 2, } } - ] + ], + 'params': { + 'playlistend': 2, + } } - - @classmethod - def suitable(cls, url): - """Receives a URL and returns True if suitable for this IE.""" - return re.match(cls._VALID_URL, url, re.VERBOSE) is not None - def _real_extract(self, url): m = re.match(self._VALID_URL, url, re.VERBOSE) gameID = m.group('gameID') @@ -64,26 +61,26 @@ class SteamIE(InfoExtractor): game_title = self._html_search_regex(r'', webpage, 'game title') - urlRE = r"'movie_(?P\d+)': \{\s*FILENAME: \"(?P[\w:/\.\?=]+)\"(,\s*MOVIE_NAME: \"(?P[\w:/\.\?=\+-]+)\")?\s*\}," - mweb = re.finditer(urlRE, webpage) - namesRE = r'(?P.+?)' - titles = re.finditer(namesRE, webpage) - thumbsRE = r'' - thumbs = re.finditer(thumbsRE, webpage) + mweb = re.finditer( + r"'movie_(?P\d+)': \{\s*FILENAME: \"(?P[\w:/\.\?=]+)\"(,\s*MOVIE_NAME: \"(?P[\w:/\.\?=\+-]+)\")?\s*\},", + webpage) + titles = re.finditer( + r'(?P.+?)', webpage) + thumbs = re.finditer( + r'', webpage) videos = [] - for vid,vtitle,thumb in zip(mweb,titles,thumbs): + for vid, vtitle, thumb in zip(mweb, titles, thumbs): video_id = vid.group('videoID') title = vtitle.group('videoName') video_url = vid.group('videoURL') video_thumb = thumb.group('thumbnail') if not video_url: raise ExtractorError('Cannot find video url for %s' % video_id) - info = { - 'id':video_id, - 'url':video_url, + videos.append({ + 'id': video_id, + 'url': video_url, 'ext': 'flv', 'title': unescapeHTML(title), 'thumbnail': video_thumb - } - videos.append(info) + }) return self.playlist_result(videos, gameID, game_title)