3 from .common
import InfoExtractor
12 class SteamIE(InfoExtractor
):
14 https?://(?:store\.steampowered|steamcommunity)\.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': '695242613303ffa2a4c44c9374ddc067',
32 'title': 'Terraria video 256785003',
33 'thumbnail': r
're:^https://cdn\.[^\.]+\.steamstatic\.com',
37 'md5': '6a294ee0c4b1f47f5bb76a65e31e3592',
41 'title': 'Terraria video 2040428',
42 'thumbnail': r
're:^https://cdn\.[^\.]+\.steamstatic\.com',
54 'url': 'https://store.steampowered.com/app/271590/Grand_Theft_Auto_V/',
57 'title': 'Grand Theft Auto V',
62 def _real_extract(self
, url
):
63 m
= self
._match
_valid
_url
(url
)
64 file_id
= m
.group('fileID')
69 game_id
= m
.group('gameID')
71 video_url
= self
._VIDEO
_PAGE
_TEMPLATE
% playlist_id
73 self
._set
_cookie
('steampowered.com', 'wants_mature_content', '1')
74 self
._set
_cookie
('steampowered.com', 'birthtime', '944006401')
75 self
._set
_cookie
('steampowered.com', 'lastagecheckage', '1-0-2000')
77 webpage
= self
._download
_webpage
(video_url
, playlist_id
)
79 if re
.search('<div[^>]+>Please enter your birth date to continue:</div>', webpage
) is not None:
80 video_url
= self
._AGECHECK
_TEMPLATE
% playlist_id
81 self
.report_age_confirmation()
82 webpage
= self
._download
_webpage
(video_url
, playlist_id
)
84 videos
= re
.findall(r
'(<div[^>]+id=[\'"]highlight_movie_(\d+)[\'"][^
>]+>)', webpage)
86 playlist_title = get_element_by_class('apphub_AppName
', webpage)
87 for movie, movie_id in videos:
90 movie = extract_attributes(movie)
95 'title
': f'{playlist_title} video {movie_id}
',
99 entry['thumbnail
'] = movie.get('data
-poster
')
100 for quality in ('', '-hd
'):
101 for ext in ('webm
', 'mp4
'):
102 video_url = movie.get(f'data
-{ext}{quality}
-source
')
105 'format_id
': ext + quality,
108 entry['formats
'] = formats
109 entries.append(entry)
110 embedded_videos = re.findall(r'(<iframe
[^
>]+>)', webpage)
111 for evideos in embedded_videos:
112 evideos = extract_attributes(evideos).get('src
')
113 video_id = self._search_regex(r'youtube\
.com
/embed
/([0-9A
-Za
-z_
-]{11}
)', evideos, 'youtube_video_id
', default=None)
116 '_type
': 'url_transparent
',
122 raise ExtractorError('Could
not find any videos
')
124 return self.playlist_result(entries, playlist_id, playlist_title)
127 class SteamCommunityBroadcastIE(InfoExtractor):
128 _VALID_URL = r'https?
://steamcommunity\
.(?
:com
)/broadcast
/watch
/(?P
<id>\d
+)'
130 'url
': 'https
://steamcommunity
.com
/broadcast
/watch
/76561199073851486',
132 'id': '76561199073851486',
133 'title
': r're
:Steam Community
:: pepperm
!nt
:: Broadcast
2022-06-26 \d{2}
:\d{2}
',
135 'uploader_id
': '1113585758',
136 'uploader
': 'pepperm
!nt
',
137 'live_status
': 'is_live
',
139 'skip
': 'Stream has ended
',
142 def _real_extract(self, url):
143 video_id = self._match_id(url)
144 webpage = self._download_webpage(url, video_id)
145 json_data = self._download_json(
146 'https
://steamcommunity
.com
/broadcast
/getbroadcastmpd
/',
147 video_id, query={'steamid
': f'{video_id}
'})
149 formats, subs = self._extract_m3u8_formats_and_subtitles(json_data['hls_url
'], video_id)
151 ''' # We cannot download live dash atm
152 mpd_formats, mpd_subs = self._extract_mpd_formats_and_subtitles(json_data['url
'], video_id)
153 formats.extend(mpd_formats)
154 self._merge_subtitles(mpd_subs, target=subs)
157 uploader_json = self._download_json(
158 'https
://steamcommunity
.com
/actions
/ajaxresolveusers
',
159 video_id, query={'steamids
': video_id})[0]
163 'title
': self._generic_title('', webpage),
165 'live_status
': 'is_live
',
166 'view_count
': json_data.get('num_view
'),
167 'uploader
': uploader_json.get('persona_name
'),
168 'uploader_id
': str_or_none(uploader_json.get('accountid
')),