]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/godtube.py
Completely change project name to yt-dlp (#85)
[yt-dlp.git] / yt_dlp / extractor / godtube.py
CommitLineData
cb3ff6fb
S
1from __future__ import unicode_literals
2
3import re
4
5from .common import InfoExtractor
6from ..utils import (
7 parse_duration,
8 parse_iso8601,
9)
10
11
12class 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',
ec85ded8 26 'thumbnail': r're:^https?://.*\.jpg$',
cb3ff6fb
S
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
2a7b4681
PH
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
cb3ff6fb
S
44
45 media = self._download_xml(
46 'http://www.godtube.com/media/xml/?v=%s' % video_id, video_id, 'Downloading media XML')
47
2a7b4681 48 title = media.find('title').text
cb3ff6fb
S
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 }