Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[caffeine.tv] Add new extractor #32514

Merged
merged 4 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions youtube_dl/extractor/caffeine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# coding: utf-8
from __future__ import unicode_literals

from .common import InfoExtractor
from ..utils import (
int_or_none,
)

import re


class CaffeineIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?caffeine\.tv/.+/video/(?P<video_id>[0-9a-f-]+)'
dirkf marked this conversation as resolved.
Show resolved Hide resolved
_TEST = {
'url': 'https://www.caffeine.tv/TsuSurf/video/cffc0a00-e73f-11ec-8080-80017d29f26e',
'info_dict': {
'id': 'cffc0a00-e73f-11ec-8080-80017d29f26e',
'ext': 'mp4',
'title': 'GOOOOD MORNINNNNN #highlights',
'uploader': 'TsuSurf',
'duration': 3145,
}
}
dirkf marked this conversation as resolved.
Show resolved Hide resolved

def _real_extract(self, url):
video_id = re.match(self._VALID_URL, url).group('video_id')
dirkf marked this conversation as resolved.
Show resolved Hide resolved
json_data = self._download_json('https://api.caffeine.tv/social/public/activity/' + video_id, video_id)
broadcast_info = json_data.get('broadcast_info')
title = broadcast_info['broadcast_title']
video_url = broadcast_info['video_url']
dirkf marked this conversation as resolved.
Show resolved Hide resolved

formats = self._extract_m3u8_formats(
video_url, video_id, 'mp4')
dirkf marked this conversation as resolved.
Show resolved Hide resolved
self._sort_formats(formats)

return {
'id': video_id,
'title': title,
'uploader': json_data['username'],
'duration': int_or_none(broadcast_info['content_duration']),
'like_count': int_or_none(json_data['like_count']),
'formats': formats,
}
dirkf marked this conversation as resolved.
Show resolved Hide resolved
dirkf marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions youtube_dl/extractor/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
from .buzzfeed import BuzzFeedIE
from .byutv import BYUtvIE
from .c56 import C56IE
from .caffeine import CaffeineIE
dirkf marked this conversation as resolved.
Show resolved Hide resolved
from .callin import CallinIE
from .camdemy import (
CamdemyIE,
Expand Down