# 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
        report_error('%s' % e.reason)
    sys.exit(1)


def vimeo_api_call(endpoint, **kargs):
    url = api_base + endpoint + '?' + url_encode(kargs)
    return vimeo_api_url(url)


def video_item_add(video):
    try:
        poster = [p['link'] for p in video['pictures']['sizes'] if p['width'] == 640][0]
        if '?' in poster: poster = poster.split('?')[0]
    except:
        poster = None
    views = video['stats']['plays'] or 0
    likes = video['metadata']['connections']['likes']['total'] or 0
    comments = video['metadata']['connections']['comments']['total'] or 0
    info = '<title>%s</> <small>%s</small><br>' \
           '<small><name>%s</> %s <name>/ %s %s</><br>' \
           '<success>%s %s</> <name>/</> ' \
           '<warning>%s %s</> <name>/</> ' \
           '<info>%s %s</></small><br>%s' % (
               video['name'], seconds_to_duration(video['duration']),
               _('user'), video['user']['name'],
               _('uploaded'), relative_date(video['created_time']),
               views, ngettext('view', 'views', views),
               likes, ngettext('like', 'likes', likes),
               comments, ngettext('comment', 'comments', comments),
               video['description'] or '')

# 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

        report_error('%s' % e.reason)
    sys.exit(1)


def vimeo_api_call(endpoint, **kargs):
    url = api_base + endpoint + '?' + url_encode(kargs)
    return vimeo_api_url(url)


def video_item_add(video):
    try:
        poster = [p['link'] for p in video['pictures']['sizes'] if p['width'] == 640][0]
        if '?' in poster: poster = poster.split('?')[0]
    except:
        poster = None
    views = video['stats']['plays'] or 0
    likes = video['metadata']['connections']['likes']['total'] or 0
    comments = video['metadata']['connections']['comments']['total'] or 0
    info = '<title>%s</> <small>%s</small><br>' \
           '<small><name>%s</> %s <name>/ %s %s</><br>' \
           '<success>%s %s</> <name>/</> ' \
           '<warning>%s %s</> <name>/</> ' \
           '<info>%s %s</></small><br>%s' % (
               video['name'], seconds_to_duration(video['duration']),
               _('user'), video['user']['name'],
               _('uploaded'), relative_date(video['created_time']),
               views, ngettext('view', 'views', views),
               likes, ngettext('like', 'likes', likes),
               comments, ngettext('comment', 'comments', comments),
               video['description'] or '')

    item_add(ST_PLAY, video['name'], video['link'], icon=icon_videos,