[peertube] Add support for generic embeds
This commit is contained in:
parent
f2fc63a5a8
commit
6bd499e8ca
|
@ -108,6 +108,7 @@ from .yapfiles import YapFilesIE
|
||||||
from .vice import ViceIE
|
from .vice import ViceIE
|
||||||
from .xfileshare import XFileShareIE
|
from .xfileshare import XFileShareIE
|
||||||
from .cloudflarestream import CloudflareStreamIE
|
from .cloudflarestream import CloudflareStreamIE
|
||||||
|
from .peertube import PeerTubeIE
|
||||||
|
|
||||||
|
|
||||||
class GenericIE(InfoExtractor):
|
class GenericIE(InfoExtractor):
|
||||||
|
@ -2012,6 +2013,15 @@ class GenericIE(InfoExtractor):
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
# PeerTube embed
|
||||||
|
'url': 'https://joinpeertube.org/fr/home/',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'home',
|
||||||
|
'title': 'Reprenez le contrôle de vos vidéos ! #JoinPeertube',
|
||||||
|
},
|
||||||
|
'playlist_count': 2,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'url': 'http://share-videos.se/auto/video/83645793?uid=13',
|
'url': 'http://share-videos.se/auto/video/83645793?uid=13',
|
||||||
'md5': 'b68d276de422ab07ee1d49388103f457',
|
'md5': 'b68d276de422ab07ee1d49388103f457',
|
||||||
|
@ -3029,6 +3039,11 @@ class GenericIE(InfoExtractor):
|
||||||
return self.playlist_from_matches(
|
return self.playlist_from_matches(
|
||||||
cloudflarestream_urls, video_id, video_title, ie=CloudflareStreamIE.ie_key())
|
cloudflarestream_urls, video_id, video_title, ie=CloudflareStreamIE.ie_key())
|
||||||
|
|
||||||
|
peertube_urls = PeerTubeIE._extract_urls(webpage)
|
||||||
|
if peertube_urls:
|
||||||
|
return self.playlist_from_matches(
|
||||||
|
peertube_urls, video_id, video_title, ie=PeerTubeIE.ie_key())
|
||||||
|
|
||||||
sharevideos_urls = [mobj.group('url') for mobj in re.finditer(
|
sharevideos_urls = [mobj.group('url') for mobj in re.finditer(
|
||||||
r'<iframe[^>]+?\bsrc\s*=\s*(["\'])(?P<url>(?:https?:)?//embed\.share-videos\.se/auto/embed/\d+\?.*?\buid=\d+.*?)\1',
|
r'<iframe[^>]+?\bsrc\s*=\s*(["\'])(?P<url>(?:https?:)?//embed\.share-videos\.se/auto/embed/\d+\?.*?\buid=\d+.*?)\1',
|
||||||
webpage)]
|
webpage)]
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import compat_str
|
from ..compat import compat_str
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
@ -13,9 +15,7 @@ from ..utils import (
|
||||||
|
|
||||||
|
|
||||||
class PeerTubeIE(InfoExtractor):
|
class PeerTubeIE(InfoExtractor):
|
||||||
_VALID_URL = r'''(?x)
|
_INSTANCES_RE = r'''(?:
|
||||||
https?://
|
|
||||||
(?:
|
|
||||||
# Taken from https://instances.joinpeertube.org/instances
|
# Taken from https://instances.joinpeertube.org/instances
|
||||||
tube\.openalgeria\.org|
|
tube\.openalgeria\.org|
|
||||||
peertube\.pointsecu\.fr|
|
peertube\.pointsecu\.fr|
|
||||||
|
@ -115,10 +115,13 @@ class PeerTubeIE(InfoExtractor):
|
||||||
peertube2\.cpy\.re|
|
peertube2\.cpy\.re|
|
||||||
videos\.tcit\.fr|
|
videos\.tcit\.fr|
|
||||||
peertube\.cpy\.re
|
peertube\.cpy\.re
|
||||||
)
|
)'''
|
||||||
|
_VALID_URL = r'''(?x)
|
||||||
|
https?://
|
||||||
|
%s
|
||||||
/(?:videos/(?:watch|embed)|api/v\d/videos)/
|
/(?:videos/(?:watch|embed)|api/v\d/videos)/
|
||||||
(?P<id>[^/?#&]+)
|
(?P<id>[^/?\#&]+)
|
||||||
'''
|
''' % _INSTANCES_RE
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://peertube.moe/videos/watch/2790feb0-8120-4e63-9af3-c943c69f5e6c',
|
'url': 'https://peertube.moe/videos/watch/2790feb0-8120-4e63-9af3-c943c69f5e6c',
|
||||||
'md5': '80f24ff364cc9d333529506a263e7feb',
|
'md5': '80f24ff364cc9d333529506a263e7feb',
|
||||||
|
@ -156,6 +159,14 @@ class PeerTubeIE(InfoExtractor):
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _extract_urls(webpage):
|
||||||
|
return [
|
||||||
|
mobj.group('url')
|
||||||
|
for mobj in re.finditer(
|
||||||
|
r'''(?x)<iframe[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?//%s/videos/embed/[^/?\#&]+)\1'''
|
||||||
|
% PeerTubeIE._INSTANCES_RE, webpage)]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue