LoginSignup
3
2

More than 5 years have passed since last update.

Pythonでアニメを順に見る

Last updated at Posted at 2015-12-04

PyPIでライブラリを揃える

pyenv local 2.7.10
pip install Animapy
pip install py-applescript

あとは下記スクリプトを実行

anime_play.py
import os
import applescript

from animapy import anime

search = raw_input('search: (string) ')
index = int(raw_input('index: (integer) '))

qt_play = applescript.AppleScript('''
    on run {arg1}
        tell Application "QuickTime Player"
            open URL arg1
        end tell
    end run
''')

qt_close = applescript.AppleScript('''
    tell Application "QuickTime Player" to close window 1
''')

def play(s):
    for ep in anime.searchAnimes(s, quant=1):
        if ep == '': continue
        url = hasattr(ep, 'hd') and ep.hd or ep.normal
        print('starting to play %s' % ep.title)
        return qt_play.run(url)

while(1):
    play('%s %03d' % (search, index))
    raw_input('Enter to next index movie: ')
    qt_close.run()
    index+=1

説明

  1. スクリプトを実行しローマ字でアニメのタイトルを入力しエンター
  2. 話数を整数で入力する
  3. エンターを押すたびに次の話数が再生される
  4. ^Cとかで終わる

注意: Macユーザー向けになっちゃった。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2