]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/wrzuta.py
debian/control: Add recommends on aria2 | wget | curl to use external downloaders.
[youtubedl] / youtube_dl / extractor / wrzuta.py
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import (
8 int_or_none,
9 qualities,
10 )
11
12
13 class WrzutaIE(InfoExtractor):
14 IE_NAME = 'wrzuta.pl'
15
16 _VALID_URL = r'https?://(?P<uploader>[0-9a-zA-Z]+)\.wrzuta\.pl/(?P<typ>film|audio)/(?P<id>[0-9a-zA-Z]+)'
17
18 _TESTS = [{
19 'url': 'http://laboratoriumdextera.wrzuta.pl/film/aq4hIZWrkBu/nike_football_the_last_game',
20 'md5': '9e67e05bed7c03b82488d87233a9efe7',
21 'info_dict': {
22 'id': 'aq4hIZWrkBu',
23 'ext': 'mp4',
24 'title': 'Nike Football: The Last Game',
25 'duration': 307,
26 'uploader_id': 'laboratoriumdextera',
27 'description': 'md5:7fb5ef3c21c5893375fda51d9b15d9cd',
28 },
29 }, {
30 'url': 'http://jolka85.wrzuta.pl/audio/063jOPX5ue2/liber_natalia_szroeder_-_teraz_ty',
31 'md5': 'bc78077859bea7bcfe4295d7d7fc9025',
32 'info_dict': {
33 'id': '063jOPX5ue2',
34 'ext': 'ogg',
35 'title': 'Liber & Natalia Szroeder - Teraz Ty',
36 'duration': 203,
37 'uploader_id': 'jolka85',
38 'description': 'md5:2d2b6340f9188c8c4cd891580e481096',
39 },
40 }]
41
42 def _real_extract(self, url):
43 mobj = re.match(self._VALID_URL, url)
44 video_id = mobj.group('id')
45 typ = mobj.group('typ')
46 uploader = mobj.group('uploader')
47
48 webpage = self._download_webpage(url, video_id)
49
50 quality = qualities(['SD', 'MQ', 'HQ', 'HD'])
51
52 audio_table = {'flv': 'mp3', 'webm': 'ogg', '???': 'mp3'}
53
54 embedpage = self._download_json('http://www.wrzuta.pl/npp/embed/%s/%s' % (uploader, video_id), video_id)
55
56 formats = []
57 for media in embedpage['url']:
58 fmt = media['type'].split('@')[0]
59 if typ == 'audio':
60 ext = audio_table.get(fmt, fmt)
61 else:
62 ext = fmt
63
64 formats.append({
65 'format_id': '%s_%s' % (ext, media['quality'].lower()),
66 'url': media['url'],
67 'ext': ext,
68 'quality': quality(media['quality']),
69 })
70
71 self._sort_formats(formats)
72
73 return {
74 'id': video_id,
75 'title': self._og_search_title(webpage),
76 'thumbnail': self._og_search_thumbnail(webpage),
77 'formats': formats,
78 'duration': int_or_none(embedpage['duration']),
79 'uploader_id': uploader,
80 'description': self._og_search_description(webpage),
81 'age_limit': embedpage.get('minimalAge', 0),
82 }