# 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
        item_add(ST_PLAY, title, 'http://fantasti.cc' + url, poster=thumb)

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


# handle the list of categories
elif STATE == ST_CATEGORIES_LIST:
    soup = fetch_url(URL, parser='bs4')

    for div in soup.findAll('div', class_='content-block-category'):
        name = div.find('span', class_='category-name').string
        url = url_base + div.find('a')['href']
        url = url.replace('category', 'search') + 'tube/'
        try:
            thumb = div.find('div', class_='thumb')['data-src']
        except KeyError:
            try:
                thumb = div.find('div', class_='thumb')['style']
                thumb = thumb.split("('", 1)[1].split("')")[0]
            except:
                thumb = None
        item_add(ST_SEARCH_RES, name, url, icon=thumb, poster=thumb)

    # read a page with a single video and play the video
elif STATE == ST_PLAY:

# 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

        item_add(ST_PLAY, title, 'http://fantasti.cc' + url, poster=thumb)

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


# handle the list of categories
elif STATE == ST_CATEGORIES_LIST:
    soup = fetch_url(URL, parser='bs4')

    for div in soup.findAll('div', class_='content-block-category'):
        name = div.find('span', class_='category-name').string
        url = url_base + div.find('a')['href']
        url = url.replace('category', 'search') + 'tube/'
        try:
            thumb = div.find('div', class_='thumb')['data-src']
        except KeyError:
            try:
                thumb = div.find('div', class_='thumb')['style']
                thumb = thumb.split("('", 1)[1].split("')")[0]
            except:
                thumb = None
        item_add(ST_SEARCH_RES, name, url, icon=thumb, poster=thumb)

    # read a page with a single video and play the video
elif STATE == ST_PLAY:

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