def diagnose_downloader_setup(): error_list = {} try: OOFDownloader() except FileNotFoundError: error_list['oof_cookies'] = BackendTranslation()['oof_cookies_not_found'] if not verify_aria2_configs_exist(): error_list['aria2_setup'] = BackendTranslation()['aria2_setup_error'] if error_list: return jsonify({'error': error_list}), 500 return jsonify({'success': 1})
def __init__(self): self.deluge_address = '{}json'.format( return_default_config_string('deluge_address')) deluge_secret = return_default_config_string('deluge_secret') self.cookies = self.create_deluge_cookies(self.deluge_address, deluge_secret) self.translate_map = BackendTranslation()
def rename_single_file_actual(self, jav_obj): try: ind_file = jav_obj['file_name'] new_file_name = jav_obj['new_file_name'] # rename os.rename(os.path.join(self.root_path, ind_file), os.path.join(self.root_path, new_file_name)) return BackendTranslation()['rename_ok_msg'].format(ind_file, new_file_name), ind_file except Exception as e: raise Exception(f'failed to renamed {ind_file} to due to {e}')
def get_set_javs(): set_type = request.args.get('set_type') page_num = request.args.get('page_num', 1) # optional search string search_string = request.args.get('search_string', '') _dedupe_car_list = [] rt_jav_objs = [] if not search_string: # parse set without search string # verify set type if set_type not in SET_TYPE_MAP: return jsonify({'error': f'{set_type} is not a supported set type'}), 400 jav_objs, max_page = javdb_set_page(SET_TYPE_MAP[set_type], page_num) else: # search by supplied string search_map = { '番号': {'function': search_by_car, 'params': {'car': search_string}}, '女优': {'function': search_for_actress, 'params': { 'javlib_actress_code': search_string, 'page_num': page_num}}, '分类': {'function': javdb_set_page, 'params': {'page_template': 'tags?c6={url_parameter}&page={page_num}', 'page_num': page_num, 'url_parameter': search_string} }, '系列': {'function': javdb_set_page, 'params': {'page_template': 'series/{url_parameter}?page={page_num}', 'page_num': page_num, 'url_parameter': search_string} } } # verify set type if set_type not in search_map: return jsonify({'error': BackendTranslation()['no_support_set_search'].format(set_type)}), 400 jav_objs, max_page = search_map[set_type]['function'](**search_map[set_type]['params']) for jav_obj in jav_objs: if jav_obj['car'] not in _dedupe_car_list: _dedupe_car_list.append(jav_obj['car']) rt_jav_objs.append(jav_obj) # looooop through DB db_conn = JavManagerDB() for jav_obj in rt_jav_objs: if db_conn.pk_exist(str(jav_obj.get('car'))): jav_obj.update( dict( db_conn.get_by_pk(str(jav_obj.get('car'))) ) ) else: jav_obj['stat'] = 2 db_conn.upcreate_jav(jav_obj) return jsonify({'success': {'jav_objs': rt_jav_objs, 'max_page': max_page}})
def jav321_search(set_type: str, search_string: str, page_num=1): def search_by_car(car: str, **kwargs): car = car.upper() jav_obj = Jav321Scraper({'car': car}).scrape_jav() db_conn = JavManagerDB() if db_conn.pk_exist(str(jav_obj.get('car'))): jav_obj.update( dict( db_conn.get_by_pk(str(jav_obj.get('car'))) ) ) else: jav_obj['stat'] = 2 db_conn.upcreate_jav(jav_obj) # use the full image (image key) instead of img (much smaller) jav_obj['img'] = jav_obj.get('image', '') return [jav_obj], 1 def search_for_actress(javlib_actress_code: str, page_num=1): search_url = 'star/{url_parameter}/{page_num}' db_conn = JavManagerDB() # get actress first page jav_objs, max_page = jav321_set_page(search_url, page_num=page_num, url_parameter=javlib_actress_code ) for jav_obj in jav_objs: if db_conn.pk_exist(str(jav_obj.get('car'))): jav_obj.update( dict( db_conn.get_by_pk(str(jav_obj.get('car'))) ) ) else: jav_obj['stat'] = 2 db_conn.upcreate_jav(jav_obj) return jav_objs, max_page search_map = { '番号': {'function': search_by_car, 'params': {'car': search_string}}, '女优': {'function': search_for_actress, 'params': { 'javlib_actress_code': search_string, 'page_num': page_num}}, '分类': {'function': jav321_set_page, 'params': {'page_template': 'genre/{url_parameter}/{page_num}', 'page_num': page_num, 'url_parameter': search_string} }, '系列': {'function': jav321_set_page, 'params': {'page_template': 'series/{url_parameter}/{page_num}', 'page_num': page_num, 'url_parameter': search_string} } } # verify set type if set_type not in search_map: raise Exception(BackendTranslation()['no_support_set_search'].format(set_type)) jav_objs, max_page = search_map[set_type]['function'](**search_map[set_type]['params']) return jav_objs, max_page
def oof_quota(): try: return jsonify({'success': OOFDownloader().check_quota()}) except FileNotFoundError: return jsonify({'error': BackendTranslation()['oof_cookies_not_found']}), 500
def __init__(self): self.cookies = self.load_local_cookies() self.translate_map = BackendTranslation()