# Path: epymc/extapi/onlinevideo.py
# ACT_DEFAULT = 0
# ACT_NONE = 1
# ACT_FOLDER = 2
# ACT_MORE = 3
# ACT_PLAY = 4
# ACT_SEARCH = 5
# def state_get():
# def language_get():
# def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT):
# def play_url(url):
# def report_error(msg):
# def local_resource(_file_, res):
# def fetch_url(url, headers=None, parser=None):
# def ydl_executable():
# def call_ydl(url):
# def url_encode(params):
# def seconds_to_duration(seconds):
# def relative_date(date):
# def format_date(date):


import sys
from epymc.extapi.onlinevideo import api_version, state_get, \
    fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \
    relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \
    ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH
elif STATE == ST_VIDEO_LIST:
    if URL.startswith(api_base):
        results = vimeo_api_url(URL)
    else:
        results = vimeo_api_call('/videos', query=URL, per_page=ITEMS_PER_PAGE)

    for video in results['data']:
        video_item_add(video)

    if results['paging']['next']:
        url = api_base + results['paging']['next']
        text = _('Load more results (%d in total)') % results['total']
        item_add(ST_VIDEO_LIST, text, url, action=ACT_MORE)


################################################################################
# channels list
################################################################################
elif STATE == ST_CHANN_LIST:
    if URL.startswith(api_base):
        results = vimeo_api_url(URL)
    else:
        results = vimeo_api_call('/channels', query=URL, per_page=ITEMS_PER_PAGE)

    for channel in results['data']:
        channel_item_add(channel)

    if results['paging']['next']:
        url = api_base + results['paging']['next']
        text = _('Load more results (%d in total)') % results['total']

# Path: epymc/extapi/onlinevideo.py
# ACT_DEFAULT = 0
# ACT_NONE = 1
# ACT_FOLDER = 2
# ACT_MORE = 3
# ACT_PLAY = 4
# ACT_SEARCH = 5
# def state_get():
# def language_get():
# def item_add(next_state, label, url, info=None, icon=None, poster=None, action=ACT_DEFAULT):
# def play_url(url):
# def report_error(msg):
# def local_resource(_file_, res):
# def fetch_url(url, headers=None, parser=None):
# def ydl_executable():
# def call_ydl(url):
# def url_encode(params):
# def seconds_to_duration(seconds):
# def relative_date(date):
# def format_date(date):


# Path: epymc/plugins/onlinevideo/vimeo/vimeo.py
import sys
from epymc.extapi.onlinevideo import api_version, state_get, \
    fetch_url, play_url, report_error, item_add, call_ydl, local_resource, \
    relative_date, seconds_to_duration, url_encode, URLError, HTTPError, \
    ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH

elif STATE == ST_VIDEO_LIST:
    if URL.startswith(api_base):
        results = vimeo_api_url(URL)
    else:
        results = vimeo_api_call('/videos', query=URL, per_page=ITEMS_PER_PAGE)

    for video in results['data']:
        video_item_add(video)

    if results['paging']['next']:
        url = api_base + results['paging']['next']
        text = _('Load more results (%d in total)') % results['total']
        item_add(ST_VIDEO_LIST, text, url, action=ACT_MORE)


################################################################################
# channels list
################################################################################
elif STATE == ST_CHANN_LIST:
    if URL.startswith(api_base):
        results = vimeo_api_url(URL)
    else:
        results = vimeo_api_call('/channels', query=URL, per_page=ITEMS_PER_PAGE)

    for channel in results['data']:
        channel_item_add(channel)

    if results['paging']['next']:
        url = api_base + results['paging']['next']
        text = _('Load more results (%d in total)') % results['total']

        item_add(ST_CHANN_LIST, text, url, action=ACT_MORE)