1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
13 class SteamIE(InfoExtractor
):
15 https?://(?:store\.steampowered|steamcommunity)\.com/
17 (?P<urltype>video|app)/ #If the page is only for videos or for a game
19 (?P<videoID>\d*)(?P<extra>\??) # For urltype == video we sometimes get the videoID
21 https?://(?:www\.)?steamcommunity\.com/sharedfiles/filedetails/\?id=(?P<fileID>[0-9]+)
23 _VIDEO_PAGE_TEMPLATE
= 'http://store.steampowered.com/video/%s/'
24 _AGECHECK_TEMPLATE
= 'http://store.steampowered.com/agecheck/video/%s/?snr=1_agecheck_agecheck__age-gate&ageDay=1&ageMonth=January&ageYear=1970'
26 'url': 'http://store.steampowered.com/video/105600/',
29 'md5': '695242613303ffa2a4c44c9374ddc067',
33 'title': 'Terraria video 256785003',
34 'thumbnail': r
're:^https://cdn\.[^\.]+\.steamstatic\.com',
39 'md5': '6a294ee0c4b1f47f5bb76a65e31e3592',
43 'title': 'Terraria video 2040428',
45 'thumbnail': r
're:^https://cdn\.[^\.]+\.steamstatic\.com',
58 'url': 'https://store.steampowered.com/app/271590/Grand_Theft_Auto_V/',
61 'title': 'Grand Theft Auto V video 256757115',
63 'thumbnail': r
're:^https://cdn\.[^\.]+\.steamstatic\.com',
68 def _real_extract(self
, url
):
69 m
= self
._match
_valid
_url
(url
)
70 fileID
= m
.group('fileID')
75 gameID
= m
.group('gameID')
77 video_url
= self
._VIDEO
_PAGE
_TEMPLATE
% playlist_id
79 self
._set
_cookie
('steampowered.com', 'wants_mature_content', '1')
80 self
._set
_cookie
('steampowered.com', 'birthtime', '944006401')
81 self
._set
_cookie
('steampowered.com', 'lastagecheckage', '1-0-2000')
83 webpage
= self
._download
_webpage
(video_url
, playlist_id
)
85 if re
.search('<div[^>]+>Please enter your birth date to continue:</div>', webpage
) is not None:
86 video_url
= self
._AGECHECK
_TEMPLATE
% playlist_id
87 self
.report_age_confirmation()
88 webpage
= self
._download
_webpage
(video_url
, playlist_id
)
90 videos
= re
.findall(r
'(<div[^>]+id=[\'"]highlight_movie_(\d+)[\'"][^
>]+>)', webpage)
92 playlist_title = get_element_by_class('apphub_AppName
', webpage)
93 for movie, movie_id in videos:
96 movie = extract_attributes(movie)
101 'title
': f'{playlist_title} video {movie_id}
',
105 entry['thumbnail
'] = movie.get('data
-poster
')
106 for quality in ('', '-hd
'):
107 for ext in ('webm
', 'mp4
'):
108 video_url = movie.get('data
-%s%s-source' % (ext, quality))
111 'format_id
': ext + quality,
114 self._sort_formats(formats)
115 entry['formats
'] = formats
116 entries.append(entry)
117 embedded_videos = re.findall(r'(<iframe
[^
>]+>)', webpage)
118 for evideos in embedded_videos:
119 evideos = extract_attributes(evideos).get('src
')
120 video_id = self._search_regex(r'youtube\
.com
/embed
/([0-9A
-Za
-z_
-]{11}
)', evideos, 'youtube_video_id
', default=None)
123 '_type
': 'url_transparent
',
129 raise ExtractorError('Could
not find any videos
')
131 return self.playlist_result(entries, playlist_id, playlist_title)