mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-09 19:00:39 +00:00
Compare commits
3 Commits
c2a8547fdc
...
df635a09a4
Author | SHA1 | Date | |
---|---|---|---|
|
df635a09a4 | ||
|
812283199a | ||
|
5c6dfc1f79 |
@ -8,6 +8,7 @@ from ..utils import (
|
||||
float_or_none,
|
||||
jwt_encode_hs256,
|
||||
try_get,
|
||||
ExtractorError,
|
||||
)
|
||||
|
||||
|
||||
@ -94,6 +95,11 @@ class ATVAtIE(InfoExtractor):
|
||||
})
|
||||
|
||||
video_id, videos_data = list(videos['data'].items())[0]
|
||||
error_msg = try_get(videos_data, lambda x: x['error']['title'])
|
||||
if error_msg == 'Geo check failed':
|
||||
self.raise_geo_restricted(error_msg)
|
||||
elif error_msg:
|
||||
raise ExtractorError(error_msg)
|
||||
entries = [
|
||||
self._extract_video_info(url, contentResource[video['id']], video)
|
||||
for video in videos_data]
|
||||
|
@ -890,6 +890,7 @@ from .mtv import (
|
||||
MTVItaliaProgrammaIE,
|
||||
)
|
||||
from .muenchentv import MuenchenTVIE
|
||||
from .murrtube import MurrtubeIE, MurrtubeUserIE
|
||||
from .musescore import MuseScoreIE
|
||||
from .musicdex import (
|
||||
MusicdexSongIE,
|
||||
|
165
yt_dlp/extractor/murrtube.py
Normal file
165
yt_dlp/extractor/murrtube.py
Normal file
@ -0,0 +1,165 @@
|
||||
# coding: utf-8
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import functools
|
||||
import json
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..utils import (
|
||||
ExtractorError,
|
||||
OnDemandPagedList,
|
||||
determine_ext,
|
||||
int_or_none,
|
||||
try_get,
|
||||
)
|
||||
|
||||
|
||||
class MurrtubeIE(InfoExtractor):
|
||||
_VALID_URL = r'''(?x)
|
||||
(?:
|
||||
murrtube:|
|
||||
https?://murrtube\.net/videos/(?P<slug>[a-z0-9\-]+)\-
|
||||
)
|
||||
(?P<id>[a-f0-9]{8}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{12})
|
||||
'''
|
||||
_TEST = {
|
||||
'url': 'https://murrtube.net/videos/inferno-x-skyler-148b6f2a-fdcc-4902-affe-9c0f41aaaca0',
|
||||
'md5': '169f494812d9a90914b42978e73aa690',
|
||||
'info_dict': {
|
||||
'id': '148b6f2a-fdcc-4902-affe-9c0f41aaaca0',
|
||||
'ext': 'mp4',
|
||||
'title': 'Inferno X Skyler',
|
||||
'description': 'Humping a very good slutty sheppy (roomate)',
|
||||
'thumbnail': r're:^https?://.*\.jpg$',
|
||||
'duration': 284,
|
||||
'uploader': 'Inferno Wolf',
|
||||
'age_limit': 18,
|
||||
'comment_count': int,
|
||||
'view_count': int,
|
||||
'like_count': int,
|
||||
'tags': ['hump', 'breed', 'Fursuit', 'murrsuit', 'bareback'],
|
||||
}
|
||||
}
|
||||
|
||||
def _download_gql(self, video_id, op, note=None, fatal=True):
|
||||
result = self._download_json(
|
||||
'https://murrtube.net/graphql',
|
||||
video_id, note, data=json.dumps(op).encode(), fatal=fatal,
|
||||
headers={'Content-Type': 'application/json'})
|
||||
return result['data']
|
||||
|
||||
def _real_extract(self, url):
|
||||
video_id = self._match_id(url)
|
||||
data = self._download_gql(video_id, {
|
||||
'operationName': 'Medium',
|
||||
'variables': {
|
||||
'id': video_id,
|
||||
},
|
||||
'query': '''\
|
||||
query Medium($id: ID!) {
|
||||
medium(id: $id) {
|
||||
title
|
||||
description
|
||||
key
|
||||
duration
|
||||
commentsCount
|
||||
likesCount
|
||||
viewsCount
|
||||
thumbnailKey
|
||||
tagList
|
||||
user {
|
||||
name
|
||||
__typename
|
||||
}
|
||||
__typename
|
||||
}
|
||||
}'''})
|
||||
meta = data['medium']
|
||||
|
||||
storage_url = 'https://storage.murrtube.net/murrtube/'
|
||||
format_url = storage_url + meta.get('key', '')
|
||||
thumbnail = storage_url + meta.get('thumbnailKey', '')
|
||||
|
||||
if determine_ext(format_url) == 'm3u8':
|
||||
formats = self._extract_m3u8_formats(
|
||||
format_url, video_id, 'mp4', entry_protocol='m3u8_native', fatal=False)
|
||||
else:
|
||||
formats = [{'url': format_url}]
|
||||
|
||||
return {
|
||||
'id': video_id,
|
||||
'title': meta.get('title'),
|
||||
'description': meta.get('description'),
|
||||
'formats': formats,
|
||||
'thumbnail': thumbnail,
|
||||
'duration': int_or_none(meta.get('duration')),
|
||||
'uploader': try_get(meta, lambda x: x['user']['name']),
|
||||
'view_count': meta.get('viewsCount'),
|
||||
'like_count': meta.get('likesCount'),
|
||||
'comment_count': meta.get('commentsCount'),
|
||||
'tags': meta.get('tagList'),
|
||||
'age_limit': 18,
|
||||
}
|
||||
|
||||
|
||||
class MurrtubeUserIE(MurrtubeIE):
|
||||
IE_DESC = 'Murrtube user profile'
|
||||
_VALID_URL = r'https?://murrtube\.net/(?P<id>[^/]+)$'
|
||||
_TEST = {
|
||||
'url': 'https://murrtube.net/stormy',
|
||||
'info_dict': {
|
||||
'id': 'stormy',
|
||||
},
|
||||
'playlist_mincount': 27,
|
||||
}
|
||||
_PAGE_SIZE = 10
|
||||
|
||||
def _fetch_page(self, username, user_id, page):
|
||||
data = self._download_gql(username, {
|
||||
'operationName': 'Media',
|
||||
'variables': {
|
||||
'limit': self._PAGE_SIZE,
|
||||
'offset': page * self._PAGE_SIZE,
|
||||
'sort': 'latest',
|
||||
'userId': user_id,
|
||||
},
|
||||
'query': '''\
|
||||
query Media($q: String, $sort: String, $userId: ID, $offset: Int!, $limit: Int!) {
|
||||
media(q: $q, sort: $sort, userId: $userId, offset: $offset, limit: $limit) {
|
||||
id
|
||||
__typename
|
||||
}
|
||||
}'''},
|
||||
'Downloading page {0}'.format(page + 1))
|
||||
if data is None:
|
||||
raise ExtractorError(f'Failed to retrieve video list for page {page + 1}')
|
||||
|
||||
media = data['media']
|
||||
|
||||
for entry in media:
|
||||
yield self.url_result('murrtube:{0}'.format(entry['id']), MurrtubeIE.ie_key())
|
||||
|
||||
def _real_extract(self, url):
|
||||
username = self._match_id(url)
|
||||
data = self._download_gql(username, {
|
||||
'operationName': 'User',
|
||||
'variables': {
|
||||
'id': username,
|
||||
},
|
||||
'query': '''\
|
||||
query User($id: ID!) {
|
||||
user(id: $id) {
|
||||
id
|
||||
__typename
|
||||
}
|
||||
}'''},
|
||||
'Downloading user info')
|
||||
if data is None:
|
||||
raise ExtractorError('Failed to fetch user info')
|
||||
|
||||
user = data['user']
|
||||
|
||||
entries = OnDemandPagedList(functools.partial(
|
||||
self._fetch_page, username, user.get('id')), self._PAGE_SIZE)
|
||||
|
||||
return self.playlist_result(entries, username)
|
@ -86,9 +86,14 @@ class TwitCastingIE(InfoExtractor):
|
||||
request_data = urlencode_postdata({
|
||||
'password': video_password,
|
||||
}, encoding='utf-8')
|
||||
webpage = self._download_webpage(
|
||||
webpage, urlh = self._download_webpage_handle(
|
||||
url, video_id, data=request_data,
|
||||
headers={'Origin': 'https://twitcasting.tv'})
|
||||
if urlh.geturl() != url and request_data:
|
||||
webpage = self._download_webpage(
|
||||
urlh.geturl(), video_id, data=request_data,
|
||||
headers={'Origin': 'https://twitcasting.tv'},
|
||||
note='Retrying authentication')
|
||||
|
||||
title = (clean_html(get_element_by_id('movietitle', webpage))
|
||||
or self._html_search_meta(['og:title', 'twitter:title'], webpage, fatal=True))
|
||||
@ -149,11 +154,12 @@ class TwitCastingIE(InfoExtractor):
|
||||
m3u8_url, video_id, ext='mp4', m3u8_id='hls',
|
||||
live=True, headers=self._M3U8_HEADERS)
|
||||
|
||||
formats.extend(self._extract_m3u8_formats(
|
||||
m3u8_url, video_id, ext='mp4', m3u8_id='source',
|
||||
live=True, query={'mode': 'source'},
|
||||
note='Downloading source quality m3u8',
|
||||
headers=self._M3U8_HEADERS, fatal=False))
|
||||
if traverse_obj(stream_server_data, ('hls', 'source')):
|
||||
formats.extend(self._extract_m3u8_formats(
|
||||
m3u8_url, video_id, ext='mp4', m3u8_id='source',
|
||||
live=True, query={'mode': 'source'},
|
||||
note='Downloading source quality m3u8',
|
||||
headers=self._M3U8_HEADERS, fatal=False))
|
||||
|
||||
if has_websockets:
|
||||
qq = qualities(['base', 'mobilesource', 'main'])
|
||||
@ -164,11 +170,12 @@ class TwitCastingIE(InfoExtractor):
|
||||
'format_id': 'ws-%s' % mode,
|
||||
'ext': 'mp4',
|
||||
'quality': qq(mode),
|
||||
'source_preference': -10,
|
||||
# TwitCasting simply sends moof atom directly over WS
|
||||
'protocol': 'websocket_frag',
|
||||
})
|
||||
|
||||
self._sort_formats(formats)
|
||||
self._sort_formats(formats, ('source',))
|
||||
|
||||
infodict = {
|
||||
'formats': formats
|
||||
|
Loading…
Reference in New Issue
Block a user