# 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 re
import json
from epymc.extapi.onlinevideo import api_version, state_get, \
    fetch_url, play_url, item_add, call_ydl, report_error, \
    ACT_NONE, ACT_FOLDER, ACT_MORE, ACT_PLAY, ACT_SEARCH
    soup = fetch_url(URL, parser='bs4')

    loop = soup.findAll('div', class_='loop')
    for div in loop:
        title = div.find('a', class_='title').string
        thumb = div.find('img', class_='img_100')['src']
        url = 'http://fantasti.cc/' + div.find('a')['href']
        try:
            # what a mess for the info ...
            infos = div.find('span', style='font-size:11px;').get_text('|', strip=True).split('|')
            info1 = infos[0].split('\n')[0].strip()
            duration = info1.split('.')[0]
            uploaded = info1.split(':')[-1]
            from_ = infos[1]
            tags = ', '.join(infos[2:])
            info = '<title>%s</title><br>' \
                   '<name>Duration:</name> %s<br>' \
                   '<name>source</name> %s <name>/ uploaded %s</name><br>' \
                   '<name>Tags:</name> %s' % \
                   (title, duration, from_, uploaded, tags)
        except:
            info = None

        item_add(ST_PLAY, title, url, poster=thumb, info=info)

    # more items...
    try:
        url = 'http://fantasti.cc/' + soup.find('a', text='next >>')['href']
        item_add(ST_VIDEO_LIST, 'More items...', url, action=ACT_MORE)
    except:

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

    soup = fetch_url(URL, parser='bs4')

    loop = soup.findAll('div', class_='loop')
    for div in loop:
        title = div.find('a', class_='title').string
        thumb = div.find('img', class_='img_100')['src']
        url = 'http://fantasti.cc/' + div.find('a')['href']
        try:
            # what a mess for the info ...
            infos = div.find('span', style='font-size:11px;').get_text('|', strip=True).split('|')
            info1 = infos[0].split('\n')[0].strip()
            duration = info1.split('.')[0]
            uploaded = info1.split(':')[-1]
            from_ = infos[1]
            tags = ', '.join(infos[2:])
            info = '<title>%s</title><br>' \
                   '<name>Duration:</name> %s<br>' \
                   '<name>source</name> %s <name>/ uploaded %s</name><br>' \
                   '<name>Tags:</name> %s' % \
                   (title, duration, from_, uploaded, tags)
        except:
            info = None

        item_add(ST_PLAY, title, url, poster=thumb, info=info)

    # more items...
    try:
        url = 'http://fantasti.cc/' + soup.find('a', text='next >>')['href']
        item_add(ST_VIDEO_LIST, 'More items...', url, action=ACT_MORE)
    except:

        pass