aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/yourupload.py
blob: 40fc4165f402722eca38cbfbc7c06cf2e4409a64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# coding: utf-8
from __future__ import unicode_literals

import re

from .common import InfoExtractor


class YourUploadIE(InfoExtractor):
    _VALID_URL = r'''(?x)https?://(?:www\.)?
        (?:yourupload\.com/watch|
           embed\.yourupload\.com|
           embed\.yucache\.net
        )/(?P<id>[A-Za-z0-9]+)
        '''
    _TESTS = [
        {
            'url': 'http://yourupload.com/watch/14i14h',
            'md5': 'bf5c2f95c4c917536e80936af7bc51e1',
            'info_dict': {
                'id': '14i14h',
                'ext': 'mp4',
                'title': 'BigBuckBunny_320x180.mp4',
                'thumbnail': 're:^https?://.*\.jpe?g',
            }
        },
        {
            'url': 'http://embed.yourupload.com/14i14h',
            'only_matching': True,
        },
        {
            'url': 'http://embed.yucache.net/14i14h?client_file_id=803349',
            'only_matching': True,
        },
    ]

    def _real_extract(self, url):
        mobj = re.match(self._VALID_URL, url)
        video_id = mobj.group('id')

        url = 'http://embed.yucache.net/{0:}'.format(video_id)
        webpage = self._download_webpage(url, video_id)

        title = self._og_search_title(webpage)
        thumbnail = self._og_search_thumbnail(webpage)
        url = self._og_search_video_url(webpage)

        formats = [{
            'format_id': 'sd',
            'url': url,
        }]

        return {
            'id': video_id,
            'title': title,
            'formats': formats,
            'thumbnail': thumbnail,
        }