def get_kaltura_id(program_id): """ Dive into the yledl internals and fetch the kaltura player id. This can be used with Chromecast """ # yledl is not available in CI, silence import warnings from yledl.streamfilters import StreamFilters # pylint: disable=import-error from yledl.http import HttpClient # pylint: disable=import-error from yledl.localization import TranslationChooser # pylint: disable=import-error from yledl.extractors import extractor_factory # pylint: disable=import-error from yledl.titleformatter import TitleFormatter # pylint: disable=import-error title_formatter = TitleFormatter() language_chooser = TranslationChooser("fin") httpclient = HttpClient(None) stream_filters = StreamFilters() url = "https://areena.yle.fi/{}".format(program_id) extractor = extractor_factory(url, stream_filters, language_chooser, httpclient) pid = extractor.program_id_from_url(url) info = extractor.program_info_for_pid(pid, url, title_formatter, None) return info.media_id.split("-")[-1]
def get_kaltura_id(program_id): """ Dive into the yledl internals and fetch the kaltura player id. This can be used with Chromecast """ from yledl.streamfilters import StreamFilters from yledl.http import HttpClient from yledl.localization import TranslationChooser from yledl.extractors import extractor_factory from yledl.titleformatter import TitleFormatter title_formatter = TitleFormatter() language_chooser = TranslationChooser('fin') httpclient = HttpClient(None) stream_filters = StreamFilters() url = 'https://areena.yle.fi/{}'.format(program_id) extractor = extractor_factory(url, stream_filters, language_chooser, httpclient) pid = extractor.program_id_from_url(url) info = extractor.program_info_for_pid(pid, url, title_formatter, None) return info.media_id.split('-')[-1]
def fetch(url, action, filters, meta_language=None): io = IOContext(destdir='/tmp/', metadata_language=meta_language) httpclient = HttpClient() title_formatter = TitleFormatter() with Capturing() as output: res = execute_action(url, action, io, httpclient, title_formatter, stream_filters = filters) assert res == RD_SUCCESS return output
def fetch(url, action, filters): # Initialize rtmpdump_binary to avoid a file system lookup in tests io = IOContext(destdir='/tmp/', rtmpdump_binary='rtmpdump') httpclient = HttpClient() title_formatter = TitleFormatter() with Capturing() as output: res = download(url, action, io, httpclient, title_formatter, stream_filters=filters, postprocess_command=None) assert res == RD_SUCCESS return output
# -*- coding: utf-8 -*- from __future__ import print_function, absolute_import, unicode_literals from yledl import StreamFilters from yledl.downloader import SubtitleDownloader from yledl.extractors import Subtitle from yledl.http import HttpClient subtitles = [ Subtitle(url='https://example.com/subtitles/fin.srt', lang='fin'), Subtitle(url='https://example.com/subtitles/swe.srt', lang='swe'), Subtitle(url='https://example.com/subtitles/smi.srt', lang='smi') ] http_client = HttpClient() subtitle_downloader = SubtitleDownloader(http_client) def test_all(): selected = subtitle_downloader.select(subtitles, StreamFilters()) assert selected == subtitles selected = subtitle_downloader.select(subtitles, StreamFilters(sublang='all')) assert selected == subtitles def test_filter_by_lang(): filters_fin = StreamFilters(sublang='fin') selected_fin = subtitle_downloader.select(subtitles, filters_fin)