]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/peertube.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
17 class PeerTubeIE(InfoExtractor
):
18 _INSTANCES_RE
= r
'''(?:
19 # Taken from https://instances.joinpeertube.org/instances
20 tube\.openalgeria\.org|
21 peertube\.pointsecu\.fr|
22 peertube\.nogafa\.org|
24 megatube\.lilomoino\.fr|
25 peertube\.tamanoir\.foucry\.net|
26 peertube\.inapurna\.org|
27 peertube\.netzspielplatz\.de|
28 video\.deadsuperhero\.com|
29 peertube\.devosi\.org|
30 peertube\.1312\.media|
31 tube\.worldofhauru\.xyz|
32 tube\.bootlicker\.party|
34 peertube\.geekshell\.fr|
36 peertube\.peshane\.net|
38 tube\.homecomputing\.fr|
39 videos\.cloudfrancois\.fr|
40 peertube\.viviers-fibre\.net|
45 peertube\.gaialabs\.ch|
46 peertube\.extremely\.online|
47 peertube\.public-infrastructure\.eu|
57 peertube\.geekael\.fr|
59 video\.anormallostpod\.ovh|
62 videos\.iut-orsay\.fr|
63 peertube\.solidev\.net|
64 videos\.symphonie-of-code\.fr|
67 peertube\.gwendalavir\.eu|
68 video\.passageenseine\.fr|
69 videos\.festivalparminous\.org|
70 peertube\.touhoppai\.moe|
71 peertube\.duckdns\.org|
73 peertube\.mastodon\.host|
74 firedragonvideos\.com|
79 peertube\.walkingmountains\.fr|
83 jp\.peertube\.network|
86 peertube\.angristan\.xyz|
87 peertube\.parleur\.net|
96 peertube\.gegeweb\.eu|
99 tube\.conferences-gesticulees\.net|
100 peertube\.datagueule\.tv|
102 meilleurtube\.delire\.party|
103 tube\.mochi\.academy|
107 peertube\.valvin\.fr|
109 video\.colibris-outilslibres\.org|
110 video\.hispagatos\.org|
113 videos\.lecygnenoir\.info|
119 _VALID_URL
= r
'''(?x)
122 /(?:videos/(?:watch|embed)|api/v\d/videos)/
126 'url': 'https://peertube.moe/videos/watch/2790feb0-8120-4e63-9af3-c943c69f5e6c',
127 'md5': '80f24ff364cc9d333529506a263e7feb',
129 'id': '2790feb0-8120-4e63-9af3-c943c69f5e6c',
132 'description': 'wow such video, so gif',
133 'thumbnail': r
're:https?://.*\.(?:jpg|png)',
134 'timestamp': 1519297480,
135 'upload_date': '20180222',
136 'uploader': 'Luclu7',
137 'uploader_id': '7fc42640-efdb-4505-a45d-a15b1a5496f1',
138 'uploder_url': 'https://peertube.nsa.ovh/accounts/luclu7',
139 'license': 'Unknown',
143 'dislike_count': int,
148 'url': 'https://peertube.tamanoir.foucry.net/videos/watch/0b04f13d-1e18-4f1d-814e-4979aa7c9c44',
149 'only_matching': True,
152 'url': 'https://tube.22decembre.eu/videos/watch/9bb88cd3-9959-46d9-9ab9-33d2bb704c39',
153 'only_matching': True,
155 'url': 'https://tube.22decembre.eu/videos/embed/fed67262-6edb-4d1c-833b-daa9085c71d7',
156 'only_matching': True,
158 'url': 'https://tube.openalgeria.org/api/v1/videos/c1875674-97d0-4c94-a058-3f7e64c962e8',
159 'only_matching': True,
163 def _extract_urls(webpage
):
166 for mobj
in re
.finditer(
167 r
'''(?x)<iframe[^>]+\bsrc=(["\'])(?P
<url
>(?
:https?
:)?
//%s/videos
/embed
/[^
/?\
#&]+)\1'''
168 % PeerTubeIE
._INSTANCES
_RE
, webpage
)]
170 def _real_extract(self
, url
):
171 video_id
= self
._match
_id
(url
)
173 video
= self
._download
_json
(
174 urljoin(url
, '/api/v1/videos/%s' % video_id
), video_id
)
176 title
= video
['name']
179 for file_
in video
['files']:
180 if not isinstance(file_
, dict):
182 file_url
= file_
.get('fileUrl')
183 if not file_url
or not isinstance(file_url
, compat_str
):
185 file_size
= int_or_none(file_
.get('size'))
187 file_
, lambda x
: x
['resolution']['label'], compat_str
)
188 f
= parse_resolution(format_id
)
191 'format_id': format_id
,
192 'filesize': file_size
,
195 self
._sort
_formats
(formats
)
197 def account_data(field
):
198 return try_get(video
, lambda x
: x
['account'][field
], compat_str
)
200 category
= try_get(video
, lambda x
: x
['category']['label'], compat_str
)
201 categories
= [category
] if category
else None
203 nsfw
= video
.get('nsfw')
205 age_limit
= 18 if nsfw
else 0
212 'description': video
.get('description'),
213 'thumbnail': urljoin(url
, video
.get('thumbnailPath')),
214 'timestamp': unified_timestamp(video
.get('publishedAt')),
215 'uploader': account_data('displayName'),
216 'uploader_id': account_data('uuid'),
217 'uploder_url': account_data('url'),
219 video
, lambda x
: x
['licence']['label'], compat_str
),
220 'duration': int_or_none(video
.get('duration')),
221 'view_count': int_or_none(video
.get('views')),
222 'like_count': int_or_none(video
.get('likes')),
223 'dislike_count': int_or_none(video
.get('dislikes')),
224 'age_limit': age_limit
,
225 'tags': try_get(video
, lambda x
: x
['tags'], list),
226 'categories': categories
,