# Path: mybs.py
# def SelStr(sel, data):
#     mp = MyHtmlParser(tidy=False)
#     mp.feed(data)
#     return mp.select(sel)
# 
# Path: comm.py
#     def echo(*args):
#     def U(dat):
#     def echo(*args):
#     def U(dat):
# def debug(*args):
# def norm_url(url):
#     def __init__(self, url, referer):
#     def __init__(self, proxy=None):
#     def get_html(self, url, raw=False, postdata=None):
#     def get_hutf(self, *param, **dd):
#     def chrome_hutf(self, url):
#     def phantom_hutf(self, url, timeout=300, refer=None, postdata=None):
#     def last_m3u8(self, src):
#     def try_m3u8(self, src):
#     def _get_m3u8_urls(self, src, data):
#     def get_outfn(self, title, ext, unum=0):
#     def align_title_num(self, t):
#     def get_total_size(self, urllist):
#     def use_dwm_merge(self, urls, title, ext, clean=True):
#     def download_urls_you_get(self, title, ext, urls, totalsize):
#     def get_real_url(self, bu, rt, uri):
#     def try_key(self, bu, rt, dn, line):
#     def wget_m3u8(self, title, url):
#     def download_m3u8(self, title, url):
#     def avconv_m3u8(self, title, ext, url):
#     def wget_urls(self, title, ext, urls, tsize):
#     def wget_one_url(self, outfn, url, unum, totalsize=0):
#     def get_one(self, url, t=UTITLE, n=False):
#     def try_playlist(self, ispl, url):
#     def get_playlist(self, page_url):
#     def clean_up(self):
#     def test(self, args):
#     def can_handle_it(cls, url):
# def get_kind_size(u, cookie=""):
# def get_total_size_st(urllist):
# def get_total_size_mt(urllist, tn=10):
#     def worker():
# def search_first(text, *patterns):
# def match1(text, *patterns):
# def c2n(cs):
# def norm_title(title):
# def start(kls):
# def run(k, args):
#     class ConnectionResetError(Exception):
# class UO(object):
# class DWM(object):
# USER_AGENT = 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36'
# USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36'
# DEBUG = False
# UTITLE = "UnknownTitle"
#     DEBUG = args.debug
#         DEBUG = True


import os
import re
import sys
from mybs import SelStr
from comm import DWM, match1, echo, start, debug, py3, get_kind_size
            from letv import LETV
        #    return title, None, [dst], None
        #echo('TTWanda has new source')
        #echo(dst)
        #sys.exit(1)
        return title, None, [dst], None

    def get_playlist(self, url):
        if '/tv/' not in url:
            return []
        url = url.split('?')[0]
        hutf = self.get_hutf(url)
        ns = SelStr('div.article-paging a', hutf)
        # href="?vid=20723618&amp;title=第01集 新局长崛起"
        urls = []
        for a in ns:
            vid = match1(a['href'], 'vid=(\d+)')
            if vid:
                urls.append((a.text, url + '?vid=' + vid))
            else:
                urls.append((a.text, url + a['href']))
        return urls

    def test(self, args):
        # /tv/ustv/945.html?vid=20723618&title=第01集%20新局长崛起
        url = 'http://www.ttwanda.com/tv/ustv/945.html'
        url = 'http://www.ttwanda.com/tv/ustv/945.html?vid=20723618&title=%E7%AC%AC01%E9%9B%86%20%E6%96%B0%E5%B1%80%E9%95%BF%E5%B4%9B%E8%B5%B7'
        html = self.get_hutf(url)


if __name__ == '__main__':

# Path: mybs.py
# def SelStr(sel, data):
#     mp = MyHtmlParser(tidy=False)
#     mp.feed(data)
#     return mp.select(sel)
# 
# Path: comm.py
#     def echo(*args):
#     def U(dat):
#     def echo(*args):
#     def U(dat):
# def debug(*args):
# def norm_url(url):
#     def __init__(self, url, referer):
#     def __init__(self, proxy=None):
#     def get_html(self, url, raw=False, postdata=None):
#     def get_hutf(self, *param, **dd):
#     def chrome_hutf(self, url):
#     def phantom_hutf(self, url, timeout=300, refer=None, postdata=None):
#     def last_m3u8(self, src):
#     def try_m3u8(self, src):
#     def _get_m3u8_urls(self, src, data):
#     def get_outfn(self, title, ext, unum=0):
#     def align_title_num(self, t):
#     def get_total_size(self, urllist):
#     def use_dwm_merge(self, urls, title, ext, clean=True):
#     def download_urls_you_get(self, title, ext, urls, totalsize):
#     def get_real_url(self, bu, rt, uri):
#     def try_key(self, bu, rt, dn, line):
#     def wget_m3u8(self, title, url):
#     def download_m3u8(self, title, url):
#     def avconv_m3u8(self, title, ext, url):
#     def wget_urls(self, title, ext, urls, tsize):
#     def wget_one_url(self, outfn, url, unum, totalsize=0):
#     def get_one(self, url, t=UTITLE, n=False):
#     def try_playlist(self, ispl, url):
#     def get_playlist(self, page_url):
#     def clean_up(self):
#     def test(self, args):
#     def can_handle_it(cls, url):
# def get_kind_size(u, cookie=""):
# def get_total_size_st(urllist):
# def get_total_size_mt(urllist, tn=10):
#     def worker():
# def search_first(text, *patterns):
# def match1(text, *patterns):
# def c2n(cs):
# def norm_title(title):
# def start(kls):
# def run(k, args):
#     class ConnectionResetError(Exception):
# class UO(object):
# class DWM(object):
# USER_AGENT = 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36'
# USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36'
# DEBUG = False
# UTITLE = "UnknownTitle"
#     DEBUG = args.debug
#         DEBUG = True


# Path: ttwanda.py
import os
import re
import sys
from mybs import SelStr
from comm import DWM, match1, echo, start, debug, py3, get_kind_size
            from letv import LETV

        #    return title, None, [dst], None
        #echo('TTWanda has new source')
        #echo(dst)
        #sys.exit(1)
        return title, None, [dst], None

    def get_playlist(self, url):
        if '/tv/' not in url:
            return []
        url = url.split('?')[0]
        hutf = self.get_hutf(url)
        ns = SelStr('div.article-paging a', hutf)
        # href="?vid=20723618&amp;title=第01集 新局长崛起"
        urls = []
        for a in ns:
            vid = match1(a['href'], 'vid=(\d+)')
            if vid:
                urls.append((a.text, url + '?vid=' + vid))
            else:
                urls.append((a.text, url + a['href']))
        return urls

    def test(self, args):
        # /tv/ustv/945.html?vid=20723618&title=第01集%20新局长崛起
        url = 'http://www.ttwanda.com/tv/ustv/945.html'
        url = 'http://www.ttwanda.com/tv/ustv/945.html?vid=20723618&title=%E7%AC%AC01%E9%9B%86%20%E6%96%B0%E5%B1%80%E9%95%BF%E5%B4%9B%E8%B5%B7'
        html = self.get_hutf(url)


if __name__ == '__main__':

    start(TTWanDa)