# 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):


from epymc.extapi.onlinevideo import api_version, state_get, \
    fetch_url, play_url, item_add, call_ydl, report_error, \
    seconds_to_duration, relative_date, url_encode, \
    ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH
ST_HOME = 0
ST_SEARCH = 1
ST_CATEGORIES = 2
# ST_PORNSTARS = 3
ST_VIDEO_LIST = 4
ST_PLAY = 69

STATE, URL = state_get()


def build_video_list(url, videos):
    for video in videos:
        title = video['title'] or 'Untitled video'
        likes = int(float(video['ratings']) / 100 * float(video['rating']))
        actors = [p['pornstar_name'] for p in video['pornstars']]
        cats = [c['category'] for c in video['categories']]
        tags = [t['tag_name'] for t in video['tags']]
        info = '<title>{}</title> <small>{}</small><br>' \
               '<small><name>{}</name> {}<br>' \
               '<success>{} {}</success> <name>/</name> ' \
               '<warning>{} {:.0f}%</warning> <name>/</name> ' \
               '<info>{} {}</info><br>' \
               '<name>{}:</name> {}<br>' \
               '<name>{}:</name> {}<br>' \
               '<name>{}:</name> {}<br>' \
            .format(
            title, video['duration'],
            _('uploaded'), relative_date(video['publish_date']),
            video['views'], ngettext('view', 'views', int(video['views'])),
            _('rated'), float(video['rating']),

# 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/pornhub/pornhub.py
from epymc.extapi.onlinevideo import api_version, state_get, \
    fetch_url, play_url, item_add, call_ydl, report_error, \
    seconds_to_duration, relative_date, url_encode, \
    ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH

ST_HOME = 0
ST_SEARCH = 1
ST_CATEGORIES = 2
# ST_PORNSTARS = 3
ST_VIDEO_LIST = 4
ST_PLAY = 69

STATE, URL = state_get()


def build_video_list(url, videos):
    for video in videos:
        title = video['title'] or 'Untitled video'
        likes = int(float(video['ratings']) / 100 * float(video['rating']))
        actors = [p['pornstar_name'] for p in video['pornstars']]
        cats = [c['category'] for c in video['categories']]
        tags = [t['tag_name'] for t in video['tags']]
        info = '<title>{}</title> <small>{}</small><br>' \
               '<small><name>{}</name> {}<br>' \
               '<success>{} {}</success> <name>/</name> ' \
               '<warning>{} {:.0f}%</warning> <name>/</name> ' \
               '<info>{} {}</info><br>' \
               '<name>{}:</name> {}<br>' \
               '<name>{}:</name> {}<br>' \
               '<name>{}:</name> {}<br>' \
            .format(
            title, video['duration'],
            _('uploaded'), relative_date(video['publish_date']),
            video['views'], ngettext('view', 'views', int(video['views'])),
            _('rated'), float(video['rating']),

            likes, ngettext('like', 'likes', likes),