3 from .common
import InfoExtractor
10 class SapoIE(InfoExtractor
):
11 IE_DESC
= 'SAPO Vídeos'
12 _VALID_URL
= r
'https?://(?:(?:v2|www)\.)?videos\.sapo\.(?:pt|cv|ao|mz|tl)/(?P<id>[\da-zA-Z]{20})'
16 'url': 'http://videos.sapo.pt/UBz95kOtiWYUMTA5Ghfi',
17 'md5': '79ee523f6ecb9233ac25075dee0eda83',
20 'id': 'UBz95kOtiWYUMTA5Ghfi',
22 'title': 'Benfica - Marcas na Hitória',
23 'description': 'md5:c9082000a128c3fd57bf0299e1367f22',
25 'uploader': 'tiago_1988',
26 'upload_date': '20080229',
27 'categories': ['benfica', 'cabral', 'desporto', 'futebol', 'geovanni', 'hooijdonk', 'joao', 'karel', 'lisboa', 'miccoli'],
31 'url': 'http://videos.sapo.pt/IyusNAZ791ZdoCY5H5IF',
32 'md5': '90a2f283cfb49193fe06e861613a72aa',
35 'id': 'IyusNAZ791ZdoCY5H5IF',
37 'title': 'Codebits VII - Report',
38 'description': 'md5:6448d6fd81ce86feac05321f354dbdc8',
40 'uploader': 'codebits',
41 'upload_date': '20140427',
42 'categories': ['codebits', 'codebits2014'],
46 'url': 'http://v2.videos.sapo.pt/yLqjzPtbTimsn2wWBKHz',
47 'md5': 'e5aa7cc0bdc6db9b33df1a48e49a15ac',
50 'id': 'yLqjzPtbTimsn2wWBKHz',
52 'title': 'Hipnose Condicionativa 4',
53 'description': 'md5:ef0481abf8fb4ae6f525088a6dadbc40',
55 'uploader': 'sapozen',
56 'upload_date': '20090609',
57 'categories': ['condicionativa', 'heloisa', 'hipnose', 'miranda', 'sapo', 'zen'],
62 def _real_extract(self
, url
):
63 mobj
= self
._match
_valid
_url
(url
)
64 video_id
= mobj
.group('id')
66 item
= self
._download
_xml
(
67 f
'http://rd3.videos.sapo.pt/{video_id}/rss2', video_id
).find('./channel/item')
69 title
= item
.find('./title').text
70 description
= item
.find('./{http://videos.sapo.pt/mrss/}synopse').text
71 thumbnail
= item
.find('./{http://search.yahoo.com/mrss/}content').get('url')
72 duration
= parse_duration(item
.find('./{http://videos.sapo.pt/mrss/}time').text
)
73 uploader
= item
.find('./{http://videos.sapo.pt/mrss/}author').text
74 upload_date
= unified_strdate(item
.find('./pubDate').text
)
75 view_count
= int(item
.find('./{http://videos.sapo.pt/mrss/}views').text
)
76 comment_count
= int(item
.find('./{http://videos.sapo.pt/mrss/}comment_count').text
)
77 tags
= item
.find('./{http://videos.sapo.pt/mrss/}tags').text
78 categories
= tags
.split() if tags
else []
79 age_limit
= 18 if item
.find('./{http://videos.sapo.pt/mrss/}m18').text
== 'true' else 0
81 video_url
= item
.find('./{http://videos.sapo.pt/mrss/}videoFile').text
82 video_size
= item
.find('./{http://videos.sapo.pt/mrss/}videoSize').text
.split('x')
88 'width': int(video_size
[0]),
89 'height': int(video_size
[1]),
92 if item
.find('./{http://videos.sapo.pt/mrss/}HD').text
== 'true':
94 'url': re
.sub(r
'/mov/1$', '/mov/39', video_url
),
104 'description': description
,
105 'thumbnail': thumbnail
,
106 'duration': duration
,
107 'uploader': uploader
,
108 'upload_date': upload_date
,
109 'view_count': view_count
,
110 'comment_count': comment_count
,
111 'categories': categories
,
112 'age_limit': age_limit
,