Ejemplo n.º 1
0
def main(args):
    global SHOWS
    parse_args(args)
    data = load_json(environ[CONF_FILE])
    save_json(data, 'data/update_save.json')
    SHOWS = load_shows()

    if SHOWS is None:
        save_json({'error': 'Shows locked'}, environ[OUT_FILE])
        print('shows locked')
        return
    for s in data:
        show = SHOWS[s['series_name_unchanged']]
        if s[SERIES_NAME] == '13 Reasons Why':
            print(s)
        if s['changed']:
            show.name_needed = s[NAME_NEEDED]
            show.status = s[STATUS]
            show.premiere = s[PREMIERE]
            show.final = s[FINAL]
            show.tvdb_id = s[TVDB_ID]
            show.genre1 = s['genre1']
            show.genre2 = s['genre2']

        if not s['series_name_unchanged'] == s[SERIES_NAME]:
            update_location(show, s[SERIES_NAME])
            SHOWS.pop(s['series_name_unchanged'], None)
            show.series_name = s[SERIES_NAME]
            SHOWS[show.series_name] = show

    update_prep.SHOWS = SHOWS
    save_json(update_prep.prep_data(), environ[OUT_FILE])
    save_shows(SHOWS)
Ejemplo n.º 2
0
def main(args):
    global SHOWS, EXCEPTIONS
    unlock()
    parse_args(args)
    data = load_json(environ[CONF_FILE])
    save_json(data, 'data/save_tree.json')
    SHOWS = load_shows()
    EXCEPTIONS = load_json(EXCEPTIONS_FILE)
    if 'title_match' not in EXCEPTIONS:
        EXCEPTIONS['title_match'] = []
    if SHOWS is None:
        save_json({'shows_locked': True}, environ[OUT_FILE])
        print('shows locked')
        return
    queue = syncer.QUEUE
    queue_errors(data['errors'], queue)
    load_all(data['shows'], queue)
    save_json(EXCEPTIONS, EXCEPTIONS_FILE)
    save_queue(queue)
    report = []
    for file in queue:
        report.append(file.get_report())
    print(dumps(report, indent=4, sort_keys=True))
    save_shows(SHOWS)

    import file_tree
    file_tree.main(out_file=environ[OUT_FILE])
Ejemplo n.º 3
0
def main(args=None, out_file='data/tree_file_comb.json'):
    global SHOWS
    SHOWS = load_shows(read_only=True)
    if args:
        parse_args(args)
        out_file = environ[OUT_FILE]

    tree_file = load_all_parallel()

    save_json(tree_file, out_file)
    save_shows(SHOWS)
    return tree_file
Ejemplo n.º 4
0
def main(args):
    global SHOWS
    parse_args(args)
    data = load_json(environ[CONF_FILE])
    save_json(data, 'data/save_words.json')
    SHOWS = load_shows()
    dictionary = load_json(DICT_FILE)

    if SHOWS is None:
        save_json({'shows_locked': True}, environ[OUT_FILE])
        print('shows locked')
        return

    for file in data['words']:
        changes = []
        for w in file['words']:
            if w['add'] and w['word'] not in dictionary:
                dictionary.append(w['word'])
            if w['changed']:
                changes.append([w['index'], w['word']])

        if changes:
            e = Episode(location=file['location'])
            old = file['file'].rsplit('.', 1)
            words = old[0].split(' ')
            for c in changes:
                words[c[0]] = c[1]
            words = list(filter(None, words))
            file['file'] = ' '.join(words)
            new_location = file['location'].replace(old[0], file['file'])
            try:
                move(file['location'], new_location)
                SHOWS[e.series_name].seasons[e.s_nr].episodes[
                    e.e_nr].set_location(new_location)
            except Exception as e:
                print('rename', e)
    if dictionary:
        save_json(dictionary, DICT_FILE)
    save_json({'done': True}, environ[OUT_FILE])
    save_shows(SHOWS)
Ejemplo n.º 5
0
def main(args):
    global SHOWS

    parse_args(args)

    data = load_json(os.environ[CONF_FILE])
    save_json(data, 'data/batch_sync.json')
    SHOWS = load_shows()
    if SHOWS is None:
        save_json({'error': 'Shows locked'}, os.environ[OUT_FILE])
        print('shows locked')
        return
    show = prep(data)

    if show:
        sync_queue(show)
        update_summary()
        clean_up()
        SHOWS[show.series_name] = show
    save_json(REPORT, os.environ[OUT_FILE])
    save_shows(SHOWS)
    return REPORT
Ejemplo n.º 6
0
def main(args):
    parse_args(args)
    unlock()
    config = load_json(environ[CONF_FILE])
    start = time()
    print('running', SERIES_DIR)
    if not backup.main():
        print('backup failed')
        exit(-2)
    else:
        print('backup successful')
    load_shows(reload=True)
    shows = load_files(SERIES_DIR)
    shows.update(load_files(ANIME_DIR))
    if config['reload_metadata']:
        shows = reload_metadata(shows)
    else:
        add_metadata(shows)
    save_shows(shows)

    print(time() - start)
    return shows
Ejemplo n.º 7
0
def main(args):
    global SHOWS
    parse_args(args)
    data = load_json(os.environ[CONF_FILE])
    save_json(data, 'data/syncer.json')
    SHOWS = load_shows()

    if SHOWS is None:
        save_json({'shows_locked': True}, os.environ[OUT_FILE])
        print('shows locked')
        return
    save_json(data, 'data/sync')
    files = []
    for f in data:

        f = File(old_location=os.path.join(FILE_DIR, f['location']),
                 sync=f['sync'],
                 s_nr=f['s_nr'],
                 e_nr=f['e_nr'],
                 series_name=f[SERIES_NAME],
                 title=f['title'],
                 title2=f['title2'],
                 title3=f['title3'],
                 episode_option=f['e_o']['s'],
                 override=f['override'],
                 delete=f['delete'],
                 subs=f['subs'],
                 type_option=f['t_o']['s'],
                 status=f['status_o']['s'],
                 new_series=f['new_series'],
                 name_needed=True if f['name_o']['s'] == 'Name required' else False,
                 tvdb_id=f['tvdb_id'] if not f['tvdb_id'] == 0 else 0,
                 anime=True if f['new_series'] and f['anime_o']['s'] == 'Anime: Yes' else False)

        if f.new_series:
            create_new_series(f)
        files.append(f)

    for file in files:
        if file.delete:
            QUEUE.append(file)
            continue
        if file.type_option == '[ignore]':
            ignore_file(file)
            continue
        if not file.sync:
            continue
        if file.type_option in ['HD', 'SD']:
            queue_movie(file)
            continue
        if file.type_option == 'Series':
            file.anime = SHOWS[file.series_name].anime
            queue_episode(file)
            continue

    sync_queue()
    clean_up()
    report = []
    for file in QUEUE:
        report.append(file.get_report())
    log = load_json(os.path.join(
        os.path.dirname(os.environ[OUT_FILE]), 'synclog'))
    if not log:
        log = []
    log.extend(report)
    save_json(report, os.environ[OUT_FILE])
    save_json(log, os.path.join(os.path.dirname(
        os.environ[OUT_FILE]), 'synclog'))
    print(json.dumps(report, indent=4, sort_keys=True))
    save_shows(SHOWS)
Ejemplo n.º 8
0
from operator import itemgetter
from tvdb_client import ApiV2Client
from series import Series
from utils.constants import SERIES_NAME, DOUBLE, TRIPLE, OUT_FILE
from utils.io_utlis import load_shows, parse_args, save_json, save_shows

SHOWS = load_shows()

for s in sorted(list(SHOWS.values()), key=lambda k: k.series_name.lower()):
    if s.genre1 == 'Anime':
        print(s)
        s.genre1 = 'Animation'
    if s.genre2 == 'Anime':
        s.genre2 = 'Animation'
        print(s)

save_shows(SHOWS)