]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/wrzuta.py
bdd7097baec16afb2a3c83dbdde0e89ebc713a69
1 # -*- coding: utf-8 -*-
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
15 class WrzutaIE(InfoExtractor
):
18 _VALID_URL
= r
'https?://(?P<uploader>[0-9a-zA-Z]+)\.wrzuta\.pl/(?P<typ>film|audio)/(?P<id>[0-9a-zA-Z]+)'
21 'url': 'http://laboratoriumdextera.wrzuta.pl/film/aq4hIZWrkBu/nike_football_the_last_game',
22 'md5': '9e67e05bed7c03b82488d87233a9efe7',
26 'title': 'Nike Football: The Last Game',
28 'uploader_id': 'laboratoriumdextera',
29 'description': 'md5:7fb5ef3c21c5893375fda51d9b15d9cd',
31 'skip': 'Redirected to wrzuta.pl',
33 'url': 'http://vexling.wrzuta.pl/audio/01xBFabGXu6/james_horner_-_into_the_na_39_vi_world_bonus',
34 'md5': 'f80564fb5a2ec6ec59705ae2bf2ba56d',
38 'title': 'James Horner - Into The Na\'vi World [Bonus]',
39 'description': 'md5:30a70718b2cd9df3120fce4445b0263b',
41 'uploader_id': 'vexling',
45 def _real_extract(self
, url
):
46 mobj
= re
.match(self
._VALID
_URL
, url
)
47 video_id
= mobj
.group('id')
48 typ
= mobj
.group('typ')
49 uploader
= mobj
.group('uploader')
51 webpage
, urlh
= self
._download
_webpage
_handle
(url
, video_id
)
53 if urlh
.geturl() == 'http://www.wrzuta.pl/':
54 raise ExtractorError('Video removed', expected
=True)
56 quality
= qualities(['SD', 'MQ', 'HQ', 'HD'])
58 audio_table
= {'flv': 'mp3', 'webm': 'ogg', '???': 'mp3'}
60 embedpage
= self
._download
_json
('http://www.wrzuta.pl/npp/embed/%s/%s' % (uploader
, video_id
), video_id
)
63 for media
in embedpage
['url']:
64 fmt
= media
['type'].split('@')[0]
66 ext
= audio_table
.get(fmt
, fmt
)
71 'format_id': '%s_%s' % (ext
, media
['quality'].lower()),
74 'quality': quality(media
['quality']),
77 self
._sort
_formats
(formats
)
81 'title': self
._og
_search
_title
(webpage
),
82 'thumbnail': self
._og
_search
_thumbnail
(webpage
),
84 'duration': int_or_none(embedpage
['duration']),
85 'uploader_id': uploader
,
86 'description': self
._og
_search
_description
(webpage
),
87 'age_limit': embedpage
.get('minimalAge', 0),
91 class WrzutaPlaylistIE(InfoExtractor
):
93 this class covers extraction of wrzuta playlist entries
94 the extraction process bases on following steps:
95 * collect information of playlist size
96 * download all entries provided on
97 the playlist webpage (the playlist is split
98 on two pages: first directly reached from webpage
99 second: downloaded on demand by ajax call and rendered
100 using the ajax call response)
101 * in case size of extracted entries not reached total number of entries
102 use the ajax call to collect the remaining entries
105 IE_NAME
= 'wrzuta.pl:playlist'
106 _VALID_URL
= r
'https?://(?P<uploader>[0-9a-zA-Z]+)\.wrzuta\.pl/playlista/(?P<id>[0-9a-zA-Z]+)'
108 'url': 'http://miromak71.wrzuta.pl/playlista/7XfO4vE84iR/moja_muza',
109 'playlist_mincount': 14,
112 'title': 'Moja muza',
115 'url': 'http://heroesf70.wrzuta.pl/playlista/6Nj3wQHx756/lipiec_-_lato_2015_muzyka_swiata',
116 'playlist_mincount': 144,
119 'title': 'Lipiec - Lato 2015 Muzyka Świata',
122 'url': 'http://miromak71.wrzuta.pl/playlista/7XfO4vE84iR',
123 'only_matching': True,
126 def _real_extract(self
, url
):
127 mobj
= re
.match(self
._VALID
_URL
, url
)
128 playlist_id
= mobj
.group('id')
129 uploader
= mobj
.group('uploader')
131 webpage
= self
._download
_webpage
(url
, playlist_id
)
133 playlist_size
= int_or_none(self
._html
_search
_regex
(
134 (r
'<div[^>]+class=["\']playlist
-counter
["\'][^>]*>\d+/(\d+)',
135 r'<div[^>]+class=["\']all
-counter
["\'][^>]*>(.+?)</div>'),
136 webpage, 'playlist size', default=None))
138 playlist_title = remove_start(
139 self._og_search_title(webpage), 'Playlista: ')
144 self.url_result(entry_url)
145 for _, entry_url in re.findall(
146 r'<a[^>]+href=(["\'])(http
.+?
)\
1[^
>]+class=["\']playlist-file-page',
148 if playlist_size > len(entries):
149 playlist_content = self._download_json(
150 'http://%s.wrzuta.pl/xhr/get_playlist_offset/%s' % (uploader, playlist_id),
152 'Downloading playlist JSON',
153 'Unable to download playlist JSON')
155 self.url_result(entry['filelink'])
156 for entry in playlist_content.get('files', []) if entry.get('filelink')])
158 return self.playlist_result(entries, playlist_id, playlist_title)