Пример #1
0
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]
Пример #2
0
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]