use config to play from a/show title
This commit is contained in:
parent
3529e01aba
commit
34f447b42d
3 changed files with 23 additions and 14 deletions
16
cdoseaplay/config.py
Normal file
16
cdoseaplay/config.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
import os
|
||||
import json
|
||||
|
||||
base = 'https://cdosea.0x2620.org/static/render/'
|
||||
lang = '1080p'
|
||||
start = ''
|
||||
conf = os.path.expanduser('~/.config/cdosea.json')
|
||||
if os.path.exists(conf):
|
||||
with open(conf) as fd:
|
||||
config = json.load(fd)
|
||||
if 'lang' in config:
|
||||
lang = config['lang']
|
||||
if 'base' in config:
|
||||
base = config['base']
|
||||
if 'start' in config:
|
||||
start = config['start']
|
|
@ -6,6 +6,7 @@ import sys
|
|||
|
||||
from .utils import update_playlist, get_player
|
||||
from .subtitleserver import SubtitleServer
|
||||
from . import config
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('cdosea')
|
||||
|
@ -28,9 +29,10 @@ def main():
|
|||
parser.add_argument('--prefix', help='video location', default=prefix)
|
||||
parser.add_argument('--window', action='store_true', help='run in window', default=False)
|
||||
parser.add_argument('--debug', action='store_true', help='debug', default=False)
|
||||
parser.add_argument('-a', '--always-a', action='store_true', help='start from A', default=False)
|
||||
args = parser.parse_args()
|
||||
|
||||
shift = config.start != 'a'
|
||||
|
||||
DEBUG = args.debug
|
||||
if DEBUG:
|
||||
log_format = '%(asctime)s:%(levelname)s:%(name)s:%(message)s'
|
||||
|
@ -47,10 +49,10 @@ def main():
|
|||
player.pause = True
|
||||
player.register_key_binding('r', restart)
|
||||
|
||||
update_playlist(args.playlist, args.prefix, shift=not args.always_a)
|
||||
update_playlist(args.playlist, args.prefix, shift=shift)
|
||||
sub = SubtitleServer(player, args.playlist)
|
||||
player.loadlist(args.playlist)
|
||||
if args.always_a:
|
||||
if not shift:
|
||||
player.pause = True
|
||||
|
||||
while True:
|
||||
|
|
|
@ -13,7 +13,8 @@ import ox
|
|||
|
||||
socket.setdefaulttimeout(10)
|
||||
|
||||
base = 'https://cdosea.0x2620.org/static/render/'
|
||||
from .config import base, lang
|
||||
|
||||
lock = '/tmp/update.lock'
|
||||
|
||||
prefix = os.path.expanduser('~/Videos/CDOSEA')
|
||||
|
@ -21,16 +22,6 @@ if not os.path.exists(prefix):
|
|||
os.makedirs(prefix)
|
||||
os.chdir(prefix)
|
||||
|
||||
lang = '1080p'
|
||||
conf = os.path.expanduser('~/.config/cdosea.json')
|
||||
if os.path.exists(conf):
|
||||
with open(conf) as fd:
|
||||
config = json.load(fd)
|
||||
if 'lang' in config:
|
||||
lang = config['lang']
|
||||
if 'base' in config:
|
||||
base = config['base']
|
||||
|
||||
def get_subtitle(url, name):
|
||||
try:
|
||||
r = requests.get(url)
|
||||
|
|
Loading…
Reference in a new issue