# Path: yledl/streamfilters.py
# class StreamFilters:
#     """Parameters for deciding which of potentially multiple available stream
#     versions to download.
#     """
#     latest_only = attr.ib(default=False)
#     maxbitrate = attr.ib(default=None)
#     maxheight = attr.ib(default=None)
#     enabled_backends = attr.ib(default=attr.Factory(
#         lambda: list(Backends.default_order)
#     ))


from datetime import datetime
from utils import fetch_title, fetch_stream_url, fetch_metadata
from yledl import StreamFilters
    assert title[0].startswith(
        'Tiedeykkönen: '
        'Suorat aurinkobiopolttoaineet mullistavat energiantuotannon')


def test_radio_title_hls():
    title = fetch_title('https://areena.yle.fi/1-4551633')

    assert len(title) == 1
    # The title changed sometime in Autumn 2021
    t = title[0]
    assert (
        t.startswith('Tiedeykkönen Extra: Ilmastonmuutos: Ihminen elää ilman vettä vain muutaman päivän')
        or t.startswith('Ilmastonmuutoksen vaikutukset: Ihminen elää ilman vettä vain muutaman päivän'))


def test_radio_stream_url_hls():
    url = fetch_stream_url('https://areena.yle.fi/1-4551633')

    assert len(url) == 1
    assert 'a.mp3' in url[0]


def test_radio_metadata_hls():
    metadata = fetch_metadata('https://areena.yle.fi/1-4551633')

    assert len(metadata) == 1
    assert len(metadata[0]['flavors']) == 1
    assert metadata[0]['flavors'][0]['media_type'] == 'audio'
    assert metadata[0]['duration_seconds'] == 2954

# Path: yledl/streamfilters.py
# class StreamFilters:
#     """Parameters for deciding which of potentially multiple available stream
#     versions to download.
#     """
#     latest_only = attr.ib(default=False)
#     maxbitrate = attr.ib(default=None)
#     maxheight = attr.ib(default=None)
#     enabled_backends = attr.ib(default=attr.Factory(
#         lambda: list(Backends.default_order)
#     ))


# Path: tests/integration/test_areena_radio_it.py
from datetime import datetime
from utils import fetch_title, fetch_stream_url, fetch_metadata
from yledl import StreamFilters

    assert title[0].startswith(
        'Tiedeykkönen: '
        'Suorat aurinkobiopolttoaineet mullistavat energiantuotannon')


def test_radio_title_hls():
    title = fetch_title('https://areena.yle.fi/1-4551633')

    assert len(title) == 1
    # The title changed sometime in Autumn 2021
    t = title[0]
    assert (
        t.startswith('Tiedeykkönen Extra: Ilmastonmuutos: Ihminen elää ilman vettä vain muutaman päivän')
        or t.startswith('Ilmastonmuutoksen vaikutukset: Ihminen elää ilman vettä vain muutaman päivän'))


def test_radio_stream_url_hls():
    url = fetch_stream_url('https://areena.yle.fi/1-4551633')

    assert len(url) == 1
    assert 'a.mp3' in url[0]


def test_radio_metadata_hls():
    metadata = fetch_metadata('https://areena.yle.fi/1-4551633')

    assert len(metadata) == 1
    assert len(metadata[0]['flavors']) == 1
    assert metadata[0]['flavors'][0]['media_type'] == 'audio'
    assert metadata[0]['duration_seconds'] == 2954

    assert len(metadata[0]['description']) > 150