コード例 #1
0
def open_wiki(*pages):
    """wikiページをウェブブラウザで開く"""
    for p in filter(None, pages):
        url = _up.urljoin('http://sougouwiki.com/d/', _libssw.quote(p))
        resp, he = _libssw.open_url(url)
        if resp.status == 200:
            dest = _libssw._rdrparser(p, he)
            if dest != p and dest != '':
                # リダイレクト先を再度読み込み
                url = _up.urljoin('http://sougouwiki.com/d/',
                                  _libssw.quote(dest))
                resp, he = _libssw.open_url(url)
            inner = he.find_class('inner')[0]
            editurl = inner.xpath('.//a')[0].get('href')
            if editurl:
                _webbrowser.open_new_tab(editurl)
        else:
            message = p + ' : ページが見つかりませんでした'
            label7.config(text=message)
コード例 #2
0
ファイル: sswchkactp.py プロジェクト: miz999/sswtools
def searchwiki_by_url(url):
    """検索結果から記事名を返すジェネレータ"""
    resp, he = libssw.open_url(
        'http://sougouwiki.com/search?keywords={}'.format(libssw.quote(url),
                                                          cache=False))

    searesult = he.find_class('result-box')[0].xpath('p[1]/strong')[0].tail

    if searesult.strip() == 'に該当するページは見つかりませんでした。':
        verbose('url not found on ssw')
        return None

    while True:
        for a in he.iterfind('.//h3[@class="keyword"]/a'):
            yield a.get('href'), a.text

        # 次のページがあったらそちらで再度探す
        he = libssw.ssw_searchnext(he)
        if he is None:
            break
コード例 #3
0
ファイル: others2ssw.py プロジェクト: miz999/sswtools
def ipondo(he, url):
    studio = '一本道'

    title = he.xpath('//h1')[0].getnext().text_content().strip()
    performers = he.xpath('//h1/a')[0].text.strip().split()

    # 検索結果ページから配信開始日を取得する
    # 検索文字列(URL)の作成
    qlist = performers[:]
    qlist.append(title)
    verbose('qlist: ', qlist)
    searchurl = 'http://www.1pondo.tv/list.php?q={}&op=and'.format('+'.join(
        libssw.quote(s) for s in qlist))
    verbose('searchurl: ', searchurl)

    release = None
    while not release:
        r, e = libssw.open_url(searchurl)
        for div in e.iterfind('.//div[@class="list_container"]/div'):
            a = div.xpath('a')[0]
            verbose('a: ', a.get('href'))
            if a.get('href') == url:
                release = libssw.extr_num(div.xpath('p')[0].text_content())
                break
        else:
            # ページ内に見つからなかったら次のページヘ
            for pagin in he.iterfind(
                    './/div[@class="listblock"]/p[@align="right"]/a'):
                if pagin.text.strip() == '次へ':
                    searchurl = 'http://www.1pondo.tv{}'.format(
                        pagin.get('href'))
                    break
            else:
                # 最後まで見つからなかったらダミーリストを返す
                emsg('W', '配信開始日を取得できませんでした。')
                release = tuple('0000', '00', '00')

    uncensored(url, release, title, studio, performers, '')
コード例 #4
0
ファイル: sswchkactp.py プロジェクト: miz999/sswtools
def main():
    args = get_args()
    verbose('args: ', args)

    # 一覧ページからチェックする作品情報を取得
    if args.from_wikitext:
        targets = OrderedDict(libssw.from_wiki((args.target, )))
        listname = libssw.from_wiki.article and libssw.from_wiki.article[0][0]
    else:
        targets = OrderedDict(libssw.from_html((args.target, ), cache=False))
        listname = libssw.from_html.article

    # 一覧ページ名の取得
    listname = args.list_name or listname
    verbose('listname: ', listname)

    if not listname:
        emsg('E', '一覧ページ名を取得できませんでした。-l オプションで指定してください。')

    # listp_url = gen_sswurl(listname)
    listp = libssw.quote(listname)
    verbose('quoted listp: ', listp)

    print('ページ名:', listname)

    not_sid = libssw.NotKeyIdYet(args.start_pid, 'start', 'pid')
    before = True if args.start_pid else False

    shortfalls = set()

    for prod_url in targets:

        # 作品情報
        props = targets[prod_url]
        verbose('props: ', props.items())

        if before and not_sid(libssw.gen_pid(prod_url)):
            continue
        else:
            before = False

        if not props.actress:
            continue

        if any('総集編' in n for n in props.note):
            continue

        print('\nTITLE: {}'.format(props.title))
        print('URL:   {}'.format(prod_url))

        notfounds = []

        # 作品の出演者情報
        for actr in props.actress:

            if not any(actr[:2]):
                continue
            else:
                shown = actr[0]
                dest = actr[1] or actr[0]

            result = ''

            print('* {}({}):'.format(dest, shown)
                  if shown != dest else '* {}:'.format(shown),
                  '...\b\b\b',
                  end='')

            rdr = libssw.follow_redirect(dest)
            if rdr and rdr != dest:
                dest = rdr
                print('(リダイレクトページ) ⇒ {}: '.format(rdr), end='')

            actr_url = gen_sswurl(dest)

            # 女優名のページをチェック
            present, link2list, linked = check_actrpage(
                actr_url, listp, prod_url)
            verbose('present: {}, link2list: {}, linked: {}'.format(
                present, link2list, linked))

            if not present:

                notfounds.append(dest)
                shortfalls.add(dest)

                if link2list == 404:
                    result += '✕ (女優ページなし)'.format(shown)
                else:
                    # 女優ページになかったら作品URLで検索してヒットしたWikiページでチェック
                    for purl, label in searchwiki_by_url(prod_url):
                        if label.startswith(dest):
                            present, link2list, linked = check_actrpage(
                                purl, listp, prod_url)
                            if present:
                                result += ' ⇒ {}'.format(label)
                                break
                    else:
                        result += '✕ (女優ページあり)'
            else:

                if linked:
                    result += '○'
                elif link2list:
                    result += '△ (他の一覧ページへのリンクあり: {})'.format(','.join(
                        '"{}"'.format(libssw.unquote(p)) for p in link2list))
                else:
                    result += '△ (一覧ページへのリンクなし)'

            print(result, actr_url)

        # ウィキテキストの作成
        if notfounds and args.gen_wikitext:
            props['title'] = ''  # 副題の時もあるので一旦リセット
            b, status, data = dmm2ssw.main(props=props,
                                           p_args=argparse.Namespace(
                                               note=args.note,
                                               series=args.series,
                                               label=args.label,
                                               linklabel=args.linklabel,
                                               hide_list=args.hide_list,
                                               smm=False))
            verbose('Return from dmm2ssw: {}, {}, {}'.format(b, status, data))
            if b:
                print()
                print(data.wktxt_a)

                if args.browser:
                    libssw.open_ssw(notfounds)
コード例 #5
0
ファイル: sswchkactp.py プロジェクト: miz999/sswtools
def gen_sswurl(name):
    return up.urljoin(BASEURL_SSW, '/d/{}'.format(libssw.quote(name)))