]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/godtube.py
Update upstream source from tag 'upstream/2020.03.24'
[youtubedl] / youtube_dl / extractor / godtube.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import (
7 parse_duration,
8 parse_iso8601,
9 )
10
11
12 class GodTubeIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:www\.)?godtube\.com/watch/\?v=(?P<id>[\da-zA-Z]+)'
14 _TESTS = [
15 {
16 'url': 'https://www.godtube.com/watch/?v=0C0CNNNU',
17 'md5': '77108c1e4ab58f48031101a1a2119789',
18 'info_dict': {
19 'id': '0C0CNNNU',
20 'ext': 'mp4',
21 'title': 'Woman at the well.',
22 'duration': 159,
23 'timestamp': 1205712000,
24 'uploader': 'beverlybmusic',
25 'upload_date': '20080317',
26 'thumbnail': r're:^https?://.*\.jpg$',
27 },
28 },
29 ]
30
31 def _real_extract(self, url):
32 mobj = re.match(self._VALID_URL, url)
33 video_id = mobj.group('id')
34
35 config = self._download_xml(
36 'http://www.godtube.com/resource/mediaplayer/%s.xml' % video_id.lower(),
37 video_id, 'Downloading player config XML')
38
39 video_url = config.find('file').text
40 uploader = config.find('author').text
41 timestamp = parse_iso8601(config.find('date').text)
42 duration = parse_duration(config.find('duration').text)
43 thumbnail = config.find('image').text
44
45 media = self._download_xml(
46 'http://www.godtube.com/media/xml/?v=%s' % video_id, video_id, 'Downloading media XML')
47
48 title = media.find('title').text
49
50 return {
51 'id': video_id,
52 'url': video_url,
53 'title': title,
54 'thumbnail': thumbnail,
55 'timestamp': timestamp,
56 'uploader': uploader,
57 'duration': duration,
58 }