1 from __future__ import unicode_literals
5 from .common import InfoExtractor
12 class SteamIE(InfoExtractor):
14 https?://store\.steampowered\.com/
16 (?P<urltype>video|app)/ #If the page is only for videos or for a game
18 (?P<videoID>\d*)(?P<extra>\??) # For urltype == video we sometimes get the videoID
20 https?://(?:www\.)?steamcommunity\.com/sharedfiles/filedetails/\?id=(?P<fileID>[0-9]+)
22 _VIDEO_PAGE_TEMPLATE = 'http://store.steampowered.com/video/%s/'
23 _AGECHECK_TEMPLATE = 'http://store.steampowered.com/agecheck/video/%s/?snr=1_agecheck_agecheck__age-gate&ageDay=1&ageMonth=January&ageYear=1970'
25 "url": "http://store.steampowered.com/video/105600/",
28 "md5": "f870007cee7065d7c76b88f0a45ecc07",
32 "title": "Terraria 1.1 Trailer",
37 "md5": "61aaf31a5c5c3041afb58fb83cbb5751",
41 "title": "Terraria Trailer",
50 'url': 'http://steamcommunity.com/sharedfiles/filedetails/?id=242472205',
54 'upload_date': '20140329',
55 'title': 'FRONTIERS - Final Greenlight Trailer',
56 'description': 'md5:dc96a773669d0ca1b36c13c1f30250d9',
57 'uploader': 'AAD Productions',
58 'uploader_id': 'AtomicAgeDogGames',
62 def _real_extract(self, url):
63 m = re.match(self._VALID_URL, url)
64 fileID = m.group('fileID')
69 gameID = m.group('gameID')
71 videourl = self._VIDEO_PAGE_TEMPLATE % playlist_id
72 webpage = self._download_webpage(videourl, playlist_id)
74 if re.search('<h2>Please enter your birth date to continue:</h2>', webpage) is not None:
75 videourl = self._AGECHECK_TEMPLATE % playlist_id
76 self.report_age_confirmation()
77 webpage = self._download_webpage(videourl, playlist_id)
80 playlist_title = self._html_search_regex(
81 r'<div class="workshopItemTitle">(.+)</div>', webpage, 'title')
82 mweb = re.finditer(r'''(?x)
83 'movie_(?P<videoID>[0-9]+)':\s*\{\s*
84 YOUTUBE_VIDEO_ID:\s*"(?P<youtube_id>[^"]+)",
88 'url': vid.group('youtube_id'),
92 playlist_title = self._html_search_regex(
93 r'<h2 class="pageheader">(.*?)</h2>', webpage, 'game title')
95 mweb = re.finditer(r'''(?x)
96 'movie_(?P<videoID>[0-9]+)':\s*\{\s*
97 FILENAME:\s*"(?P<videoURL>[\w:/\.\?=]+)"
98 (,\s*MOVIE_NAME:\s*\"(?P<videoName>[\w:/\.\?=\+-]+)\")?\s*\},
100 titles = re.finditer(
101 r'<span class="title">(?P<videoName>.+?)</span>', webpage)
102 thumbs = re.finditer(
103 r'<img class="movie_thumb" src="(?P<thumbnail>.+?)">', webpage)
106 for vid, vtitle, thumb in zip(mweb, titles, thumbs):
107 video_id = vid.group('videoID')
108 title = vtitle.group('videoName')
109 video_url = vid.group('videoURL')
110 video_thumb = thumb.group('thumbnail')
112 raise ExtractorError('Cannot find video url for %s' % video_id)
117 'title': unescapeHTML(title),
118 'thumbnail': video_thumb
121 raise ExtractorError('Could not find any videos')
123 return self.playlist_result(videos, playlist_id, playlist_title)