]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/steam.py
3 from .common
import InfoExtractor
10 class SteamIE(InfoExtractor
):
11 _VALID_URL
= r
"""http://store\.steampowered\.com/
13 (?P<urltype>video|app)/ #If the page is only for videos or for a game
15 (?P<videoID>\d*)(?P<extra>\??) #For urltype == video we sometimes get the videoID
17 _VIDEO_PAGE_TEMPLATE
= 'http://store.steampowered.com/video/%s/'
18 _AGECHECK_TEMPLATE
= 'http://store.steampowered.com/agecheck/video/%s/?snr=1_agecheck_agecheck__age-gate&ageDay=1&ageMonth=January&ageYear=1970'
20 u
"url": u
"http://store.steampowered.com/video/105600/",
23 u
"file": u
"81300.flv",
24 u
"md5": u
"f870007cee7065d7c76b88f0a45ecc07",
26 u
"title": u
"Terraria 1.1 Trailer"
30 u
"file": u
"80859.flv",
31 u
"md5": u
"61aaf31a5c5c3041afb58fb83cbb5751",
33 u
"title": u
"Terraria Trailer"
41 def suitable(cls
, url
):
42 """Receives a URL and returns True if suitable for this IE."""
43 return re
.match(cls
._VALID
_URL
, url
, re
.VERBOSE
) is not None
45 def _real_extract(self
, url
):
46 m
= re
.match(self
._VALID
_URL
, url
, re
.VERBOSE
)
47 gameID
= m
.group('gameID')
49 videourl
= self
._VIDEO
_PAGE
_TEMPLATE
% gameID
50 webpage
= self
._download
_webpage
(videourl
, gameID
)
52 if re
.search('<h2>Please enter your birth date to continue:</h2>', webpage
) is not None:
53 videourl
= self
._AGECHECK
_TEMPLATE
% gameID
54 self
.report_age_confirmation()
55 webpage
= self
._download
_webpage
(videourl
, gameID
)
57 self
.report_extraction(gameID
)
58 game_title
= self
._html
_search
_regex
(r
'<h2 class="pageheader">(.*?)</h2>',
59 webpage
, 'game title')
61 urlRE
= r
"'movie_(?P<videoID>\d+)': \{\s*FILENAME: \"(?P
<videoURL
>[\w
:/\
.\?=]+)\"(,\s
*MOVIE_NAME
: \"(?P
<videoName
>[\w
:/\
.\?=\
+-]+)\")?\s
*\
},"
62 mweb = re.finditer(urlRE, webpage)
63 namesRE = r'<span class="title
">(?P<videoName>.+?)</span>'
64 titles = re.finditer(namesRE, webpage)
65 thumbsRE = r'<img class="movie_thumb
" src="(?P
<thumbnail
>.+?
)">'
66 thumbs = re.finditer(thumbsRE, webpage)
68 for vid,vtitle,thumb in zip(mweb,titles,thumbs):
69 video_id = vid.group('videoID')
70 title = vtitle.group('videoName')
71 video_url = vid.group('videoURL')
72 video_thumb = thumb.group('thumbnail')
74 raise ExtractorError(u'Cannot find video url for %s' % video_id)
79 'title': unescapeHTML(title),
80 'thumbnail': video_thumb
83 return [self.playlist_result(videos, gameID, game_title)]