Exemplo n.º 1
0
def is_globoplay_mais_canais_available():
    if not control.is_globoplay_mais_canais_ao_vivo_available():
        return False

    return control.globoplay_ignore_channel_authorization(
    ) or auth_helper.is_service_allowed(
        auth_helper.CADUN_SERVICES.GSAT_CHANNELS)
Exemplo n.º 2
0
def get_live_channels():

    affiliate_id = control.setting('globo_affiliate')

    affiliates = control.get_affiliates_by_id(int(affiliate_id))

    live = []

    show_globo_internacional = control.setting(
        'show_globo_international') == 'true'

    if len(
            affiliates
    ) == 1 and not show_globo_internacional and not is_globoplay_mais_canais_available(
    ):
        affiliate = __get_affiliate_live_channels(affiliates[0])
        live.extend(affiliate)
    else:
        threads = [
            workers.Thread(__get_affiliate_live_channels, affiliate)
            for affiliate in affiliates
        ]
        if is_globoplay_mais_canais_available():
            threads.append(workers.Thread(get_mais_canais))
        if show_globo_internacional:
            threads.append(workers.Thread(get_globo_americas))
        [i.start() for i in threads]
        [i.join() for i in threads]
        [live.extend(i.get_result() or []) for i in threads]

    seen = []
    filtered_channels = filter(
        lambda x: seen.append(x['affiliate_code']
                              if 'affiliate_code' in x else '$FOO$') is None
        if 'affiliate_code' not in x or x['affiliate_code'] not in seen else
        False, live)

    if not control.globoplay_ignore_channel_authorization():
        service_ids = [
            channel.get('service_id') for channel in filtered_channels
        ]
        authorized_service_ids = get_authorized_services(service_ids)
        filtered_channels = [
            channel for channel in filtered_channels
            if not channel.get('service_id') or (
                channel.get('service_id') in authorized_service_ids)
        ]

    return filtered_channels
Exemplo n.º 3
0
def get_authorized_services(service_ids):
    if not service_ids:
        return []

    if control.globoplay_ignore_channel_authorization():
        return service_ids

    if len(service_ids) == 1:
        return [
            service_id for index, service_id in enumerate(service_ids)
            if auth_helper.is_service_allowed(service_id)
        ]
    else:
        threads = [
            workers.Thread(auth_helper.is_service_allowed, service_id)
            for service_id in service_ids
        ]
        [t.start() for t in threads]
        [t.join() for t in threads]
        [t.kill() for t in threads]
        return [
            service_id for index, service_id in enumerate(service_ids)
            if threads[index].get_result()
        ]