1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
6 from .common import InfoExtractor
14 class WrzutaIE(InfoExtractor):
17 _VALID_URL = r'https?://(?P<uploader>[0-9a-zA-Z]+)\.wrzuta\.pl/(?P<typ>film|audio)/(?P<id>[0-9a-zA-Z]+)'
20 'url': 'http://laboratoriumdextera.wrzuta.pl/film/aq4hIZWrkBu/nike_football_the_last_game',
21 'md5': '9e67e05bed7c03b82488d87233a9efe7',
25 'title': 'Nike Football: The Last Game',
27 'uploader_id': 'laboratoriumdextera',
28 'description': 'md5:7fb5ef3c21c5893375fda51d9b15d9cd',
31 'url': 'http://jolka85.wrzuta.pl/audio/063jOPX5ue2/liber_natalia_szroeder_-_teraz_ty',
32 'md5': 'bc78077859bea7bcfe4295d7d7fc9025',
36 'title': 'Liber & Natalia Szroeder - Teraz Ty',
38 'uploader_id': 'jolka85',
39 'description': 'md5:2d2b6340f9188c8c4cd891580e481096',
43 def _real_extract(self, url):
44 mobj = re.match(self._VALID_URL, url)
45 video_id = mobj.group('id')
46 typ = mobj.group('typ')
47 uploader = mobj.group('uploader')
49 webpage = self._download_webpage(url, video_id)
51 quality = qualities(['SD', 'MQ', 'HQ', 'HD'])
53 audio_table = {'flv': 'mp3', 'webm': 'ogg', '???': 'mp3'}
55 embedpage = self._download_json('http://www.wrzuta.pl/npp/embed/%s/%s' % (uploader, video_id), video_id)
58 for media in embedpage['url']:
59 fmt = media['type'].split('@')[0]
61 ext = audio_table.get(fmt, fmt)
66 'format_id': '%s_%s' % (ext, media['quality'].lower()),
69 'quality': quality(media['quality']),
72 self._sort_formats(formats)
76 'title': self._og_search_title(webpage),
77 'thumbnail': self._og_search_thumbnail(webpage),
79 'duration': int_or_none(embedpage['duration']),
80 'uploader_id': uploader,
81 'description': self._og_search_description(webpage),
82 'age_limit': embedpage.get('minimalAge', 0),
86 class WrzutaPlaylistIE(InfoExtractor):
88 this class covers extraction of wrzuta playlist entries
89 the extraction process bases on following steps:
90 * collect information of playlist size
91 * download all entries provided on
92 the playlist webpage (the playlist is split
93 on two pages: first directly reached from webpage
94 second: downloaded on demand by ajax call and rendered
95 using the ajax call response)
96 * in case size of extracted entries not reached total number of entries
97 use the ajax call to collect the remaining entries
100 IE_NAME = 'wrzuta.pl:playlist'
101 _VALID_URL = r'https?://(?P<uploader>[0-9a-zA-Z]+)\.wrzuta\.pl/playlista/(?P<id>[0-9a-zA-Z]+)'
103 'url': 'http://miromak71.wrzuta.pl/playlista/7XfO4vE84iR/moja_muza',
104 'playlist_mincount': 14,
107 'title': 'Moja muza',
110 'url': 'http://heroesf70.wrzuta.pl/playlista/6Nj3wQHx756/lipiec_-_lato_2015_muzyka_swiata',
111 'playlist_mincount': 144,
114 'title': 'Lipiec - Lato 2015 Muzyka Ĺwiata',
117 'url': 'http://miromak71.wrzuta.pl/playlista/7XfO4vE84iR',
118 'only_matching': True,
121 def _real_extract(self, url):
122 mobj = re.match(self._VALID_URL, url)
123 playlist_id = mobj.group('id')
124 uploader = mobj.group('uploader')
126 webpage = self._download_webpage(url, playlist_id)
128 playlist_size = int_or_none(self._html_search_regex(
129 (r'<div[^>]+class=["\']playlist-counter["\'][^>]*>\d+/(\d+)',
130 r'<div[^>]+class=["\']all-counter["\'][^>]*>(.+?)</div>'),
131 webpage, 'playlist size', default=None))
133 playlist_title = remove_start(
134 self._og_search_title(webpage), 'Playlista: ')
139 self.url_result(entry_url)
140 for _, entry_url in re.findall(
141 r'<a[^>]+href=(["\'])(http.+?)\1[^>]+class=["\']playlist-file-page',
143 if playlist_size > len(entries):
144 playlist_content = self._download_json(
145 'http://%s.wrzuta.pl/xhr/get_playlist_offset/%s' % (uploader, playlist_id),
147 'Downloading playlist JSON',
148 'Unable to download playlist JSON')
150 self.url_result(entry['filelink'])
151 for entry in playlist_content.get('files', []) if entry.get('filelink')])
153 return self.playlist_result(entries, playlist_id, playlist_title)