예제 #1
0
 def parse_actors(self):
     new_actor_codes = JsonWorker.sub_json(
         self.path + '\\files\\actors.json',
         self.path + '\\files\\films_db.json')
     new_torrents = None
     if new_actor_codes:
         new_torrents = ActorsParser.echo_new_films(
             new_actor_codes,
             JsonWorker.json_to_dict(self.path + '\\files\\films_db.json'))
     print('Добавлено новых раздач:', len(new_actor_codes), sep=' ')
     data = JsonWorker.json_to_dict(
         os.path.join(self.path, 'files\\actors.json'))
     with Pool(cpu_count()) as pool:
         actors = pool.map(self.actors, new_actor_codes)
     for actor in actors:
         data[actor[0]] = actor[1]
     JsonWorker.dict_to_json(os.path.join(self.path, 'files\\actors.json'),
                             data)
     return new_torrents
예제 #2
0
def download_torrent_file(codes, _all):
    """Загружает торрент файлы по ключам"""
    if _all:
        data = JsonWorker.json_to_dict(os.path.join(path, 'files\\temp.json'))
        if not data:
            print('Файл temp.json пуст')
            return
        codes = data.keys()
    else:
        data = JsonWorker.json_to_dict(
            os.path.join(path, 'files\\films_db.json'))

    with click.progressbar(codes,
                           label='Сохранение torrent файлов',
                           empty_char='.') as bar:
        for code in bar:
            if code not in data.keys():
                print('Фильма с ключом:', code, 'нет в базе данных', sep=' ')
                return
            parser.download_torrent_file(code, data.get(code)['Description'])

    JsonWorker.dict_to_json(os.path.join(path, 'files\\temp.json'), None)
    click.echo('Загрузка файлов успешно завершена')
예제 #3
0
def update_db():
    # Обновление базы данных фильмов
    click.echo(
        'Обновление базы данных, подождите это займёт несколько минут...')

    # data = main()
    # print(f'Всего раздач {len(data)}')
    # JsonWorker.dict_to_json(os.path.join(path, 'files\\films_db.json'), data)
    # JsonWorker.dict_to_json(os.path.join(path, 'files\\films_db.json'), update_db_in_ram())

    update_db_in_ram()
    print('Сортировка ...')
    data = JsonWorker.json_to_dict(os.path.join(path, 'files\\films_db.json'))
    print('Всего раздач:', len(data), sep=' ')
    JsonWorker.dict_to_json(os.path.join(path, 'files\\films_db.json'),
                            sort_dict_by_value(data))
예제 #4
0
파일: services.py 프로젝트: kykiles/uparser
 def top250(self):
     top250 = JsonWorker.json_to_dict(
         os.path.join(self._PATH, 'films_with_rating.json'))
     return top250
예제 #5
0
파일: services.py 프로젝트: kykiles/uparser
 def __init__(self):
     self._PATH = os.path.dirname(os.path.abspath(__file__))
     self._PARSER = ParserFilms()
     self._DATA = JsonWorker.json_to_dict('films_db.json')
예제 #6
0
 def __init__(self):
     self.path = os.path.dirname(os.path.abspath(__file__))
     self._data = JsonWorker.json_to_dict(
         os.path.join(self.path, 'files\\actors_list.json'))