Example #1
0
def getDataFromJSON(file_number):  #从JSON返回元数据
    global title
    global studio
    global year
    global outline
    global runtime
    global director
    global actor_list
    global actor
    global release
    global number
    global cover
    global imagecut
    global tag
    global image_main
    global cn_sub
    global website
    global actor_photo

    global naming_rule
    global location_rule

    # ================================================网站规则添加开始================================================

    try:  # 添加 需要 正则表达式的规则
        # =======================javdb.py=======================
        if re.search('^\d{5,}', file_number).group() in file_number:
            json_data = json.loads(javbus.main_uncensored(file_number))
    except:  # 添加 无需 正则表达式的规则
        # ====================fc2fans_club.py====================
        if 'fc2' in file_number:
            json_data = json.loads(
                fc2fans_club.main(
                    file_number.strip('fc2_').strip('fc2-').strip(
                        'ppv-').strip('PPV-').strip('FC2_').strip(
                            'FC2-').strip('ppv-').strip('PPV-')))
        elif 'FC2' in file_number:
            json_data = json.loads(
                fc2fans_club.main(
                    file_number.strip('FC2_').strip('FC2-').strip(
                        'ppv-').strip('PPV-').strip('fc2_').strip(
                            'fc2-').strip('ppv-').strip('PPV-')))
        # =======================javbus.py=======================
        else:
            json_data = json.loads(javbus.main(file_number))

    # ================================================网站规则添加结束================================================

    title = str(json_data['title']).replace(' ', '')
    studio = json_data['studio']
    year = json_data['year']
    outline = json_data['outline']
    runtime = json_data['runtime']
    director = json_data['director']
    actor_list = str(json_data['actor']).strip("[ ]").replace("'", '').split(
        ',')  # 字符串转列表
    release = json_data['release']
    number = json_data['number']
    cover = json_data['cover']
    imagecut = json_data['imagecut']
    tag = str(json_data['tag']).strip("[ ]").replace("'", '').replace(
        " ", '').split(',')  # 字符串转列表
    actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '')
    actor_photo = json_data['actor_photo']
    website = json_data['website']

    if title == '' or number == '':
        print('[-]Movie Data not found!')
        moveFailedFolder()

    # ====================处理异常字符====================== #\/:*?"<>|
    if '\\' in title:
        title = title.replace('\\', ' ')
    elif '/' in title:
        title = title.replace('/', '')
    elif ':' in title:
        title = title.replace('/', '')
    elif '*' in title:
        title = title.replace('*', '')
    elif '?' in title:
        title = title.replace('?', '')
    elif '"' in title:
        title = title.replace('"', '')
    elif '<' in title:
        title = title.replace('<', '')
    elif '>' in title:
        title = title.replace('>', '')
    elif '|' in title:
        title = title.replace('|', '')
    # ====================处理异常字符 END================== #\/:*?"<>|

    naming_rule = eval(config['Name_Rule']['naming_rule'])
    location_rule = eval(config['Name_Rule']['location_rule'])
Example #2
0
def getNumberFromFilename(filepath):
    global title
    global studio
    global year
    global outline
    global runtime
    global director
    global actor
    global release
    global number
    global cover
    global imagecut

    filename = str(os.path.basename(filepath))  #电影文件名
    str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filename))
    print("[!]Making Data for [" + filename + "]")
    a = str(re.search('\w+-\w+', filename).group())
    #print(a)

    # =======================网站规则添加==============================
    try:
        try:
            if re.search('^\d{5,}', a).group() in filename:
                json_data = json.loads(
                    javbus.main_uncensored(a.replace("-", "_")))
        except:
            if 'fc2' in filename:
                json_data = json.loads(fc2fans_club.main(a))
            elif 'FC2' in filename:
                json_data = json.loads(fc2fans_club.main(a))
            elif 'siro' in filename:
                json_data = json.loads(siro.main(a))
            elif 'SIRO' in filename:
                json_data = json.loads(siro.main(a))
            elif '259luxu' in filename:
                json_data = json.loads(siro.main(a))
            elif '259LUXU' in filename:
                json_data = json.loads(siro.main(a))
            else:
                json_data = json.loads(javbus.main(a))
        # ====================网站规则添加结束==============================

        title = json_data['title']
        studio = json_data['studio']
        year = json_data['year']
        outline = json_data['outline']
        runtime = json_data['runtime']
        director = json_data['director']
        actor = json_data['actor']
        release = json_data['release']
        number = json_data['number']
        cover = json_data['cover']
        imagecut = json_data['imagecut']
    except:
        print('[-]File ' + filename + '`s number can not be caught')
        print('[-]Move ' + filename + ' to failed folder')
        if not os.path.exists('failed/'):  # 新建failed文件夹
            os.makedirs('failed/')
            if not os.path.exists('failed/'):
                print(
                    "[-]failed!Dirs can not be make (Please run as Administrator)"
                )
                time.sleep(3)
                os._exit(0)
        shutil.move(filepath, str(os.getcwd()) + '/' + 'failed/')
        os._exit(0)
Example #3
0
def getDataFromJSON(file_number, config, mode):  # 从JSON返回元数据
    # ================================================网站规则添加开始================================================
    json_data = {}
    if mode == 1:  # 从全部网站刮削
        # =======================================================================无码抓取:111111-111,n1111,HEYZO-1111
        if re.match('^\d{4,}', file_number) or re.match(
                'n\d{4}', file_number) or 'HEYZO' in file_number.upper():
            json_data = json.loads(javbus.main_uncensored(file_number))
            if getDataState(json_data) == 0:
                json_data = json.loads(javdb.main(file_number))
            if getDataState(json_data) == 0:
                json_data = json.loads(avsox.main(file_number))
        # =======================================================================259LUXU-1111
        elif re.match('\d+\D+', file_number):
            json_data = json.loads(siro.main(file_number))
            if getDataState(json_data) == 0:
                json_data = json.loads(javbus.main(file_number))
            if getDataState(json_data) == 0:
                json_data = json.loads(javdb.main(file_number))
        # =======================================================================FC2-111111
        elif 'FC2' in file_number.upper():
            json_data = json.loads(
                fc2fans_club.main(
                    file_number.replace('fc2-',
                                        '').replace('fc2_', '').replace(
                                            'FC2-', '').replace('fc2_', '')))
            if getDataState(json_data) == 0:
                json_data = json.loads(javdb.main(file_number))
        # =======================================================================SIRO-111
        elif 'SIRO' in file_number.upper():
            json_data = json.loads(siro.main(file_number))
            if getDataState(json_data) == 0:
                json_data = json.loads(javdb.main(file_number))
        # =======================================================================ssni00321
        elif re.match('\D{2,}00\d{3,}', file_number
                      ) and '-' not in file_number and '_' not in file_number:
            json_data = json.loads(fanza.main(file_number))
        # =======================================================================MIDE-139
        else:
            json_data = json.loads(javbus.main(file_number))
            if getDataState(json_data) == 0:
                json_data = json.loads(
                    javlibrary.main(file_number,
                                    config['javlibrary_url']['url']))
            if getDataState(json_data) == 0:
                json_data = json.loads(javdb.main(file_number))
            if getDataState(json_data) == 0:
                json_data = json.loads(avsox.main(file_number))
            if getDataState(json_data) == 0:
                json_data = json.loads(mgstage.main(file_number))

    elif mode != 6 and re.match('\D{2,}00\d{3,}', file_number):
        json_data = {
            'title': '',
            'actor': '',
            'website': '',
        }
    elif mode == 2:  # 仅从javdb
        json_data = json.loads(javdb.main(file_number))
    elif mode == 3:  # 仅从javbus
        if re.match('^\d{5,}', file_number) or re.match(
                'n\d{4}', file_number) or 'HEYZO' in file_number.upper():
            json_data = json.loads(javbus.main_uncensored(file_number))
        else:
            json_data = json.loads(javbus.main(file_number))
    elif mode == 4:  # 仅从avsox
        json_data = json.loads(avsox.main(file_number))
    elif mode == 5:  # 仅从fc2club
        json_data = json.loads(fc2fans_club.main(file_number))
    elif mode == 6:  # 仅从fanza
        json_data = json.loads(fanza.main(file_number))
    elif mode == 7:  # 仅从siro
        json_data = json.loads(siro.main(file_number))
    elif mode == 8:  # 仅从javlibrary
        json_data = json.loads(
            javlibrary.main(file_number, config['javlibrary_url']['url']))

    # ================================================网站规则添加结束================================================
    # print(json_data)
    # ======================================超时或未找到
    if json_data['website'] == 'timeout':
        return json_data
    elif json_data['title'] == '':
        return json_data
    # ======================================处理得到的信息
    title = json_data['title']
    number = json_data['number']
    actor_list = str(json_data['actor']).strip("[ ]").replace("'", '').split(
        ',')  # 字符串转列表
    release = json_data['release']
    try:
        cover_small = json_data['cover_small']
    except:
        cover_small = ''
    tag = str(json_data['tag']).strip("[ ]").replace("'", '').replace(
        " ", '').split(',')  # 字符串转列表 @
    actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '')
    if actor == '':
        actor = 'Unknown'

    # ====================处理异常字符====================== #\/:*?"<>|
    title = title.replace('\\', '')
    title = title.replace('/', '')
    title = title.replace(':', '')
    title = title.replace('*', '')
    title = title.replace('?', '')
    title = title.replace('"', '')
    title = title.replace('<', '')
    title = title.replace('>', '')
    title = title.replace('|', '')
    title = title.replace(' ', '')
    title = title.replace('【', '')
    title = title.replace('】', '')
    release = release.replace('/', '-')
    tmpArr = cover_small.split(',')
    if len(tmpArr) > 0:
        cover_small = tmpArr[0].strip('\"').strip('\'')
    for key, value in json_data.items():
        if key == 'title' or key == 'studio' or key == 'director' or key == 'series' or key == 'publisher':
            json_data[key] = str(value).replace('/', '')
    # ====================处理异常字符 END================== #\/:*?"<>|

    naming_media = config['Name_Rule']['naming_media']
    naming_file = config['Name_Rule']['naming_file']
    folder_name = config['Name_Rule']['folder_name']

    # 返回处理后的json_data
    json_data['title'] = title
    json_data['number'] = number
    json_data['actor'] = actor
    json_data['release'] = release
    json_data['cover_small'] = cover_small
    json_data['tag'] = tag
    json_data['naming_media'] = naming_media
    json_data['naming_file'] = naming_file
    json_data['folder_name'] = folder_name
    return json_data
Example #4
0
def getNumberFromFilename(filepath):
    global title
    global studio
    global year
    global outline
    global runtime
    global director
    global actor_list
    global actor
    global release
    global number
    global cover
    global imagecut
    global tag

    global naming_rule
    global location_rule

    #================================================获取文件番号================================================
    try:  #试图提取番号
        # ====番号获取主程序====
        try:  # 普通提取番号 主要处理包含减号-的番号
            filepath.strip('22-sht.me').strip('-HD').strip('-hd')
            filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "",
                                  filepath))  # 去除文件名中文件名
            file_number = re.search('\w+-\d+', filename).group()
        except:  # 提取不含减号-的番号
            try:  # 提取东京热番号格式 n1087
                filename1 = str(
                    re.sub("h26\d", "",
                           filepath)).strip('Tokyo-hot').strip('tokyo-hot')
                filename0 = str(re.sub(".*?\.com-\d+", "",
                                       filename1)).strip('_')
                file_number = str(re.search('n\d{4}', filename0).group(0))
            except:  # 提取无减号番号
                filename1 = str(re.sub("h26\d", "", filepath))  # 去除h264/265
                filename0 = str(re.sub(".*?\.com-\d+", "", filename1))
                file_number2 = str(re.match('\w+', filename0).group())
                file_number = str(
                    file_number2.replace(
                        re.match("^[A-Za-z]+", file_number2).group(),
                        re.match("^[A-Za-z]+", file_number2).group() + '-'))
                if not re.search('\w-', file_number).group() == 'None':
                    file_number = re.search('\w+-\w+', filename).group()
                #上面是插入减号-到番号中
        print("[!]Making Data for   [" + filename + "],the number is [" +
              file_number + "]")
    # ====番号获取主程序=结束===
    except Exception as e:  #番号提取异常
        print('[-]' + str(os.path.basename(filepath)) +
              ' Cannot catch the number :')
        print('[-]' + str(os.path.basename(filepath)) + ' :', e)
        print('[-]Move ' + os.path.basename(filepath) + ' to failed folder')
        shutil.move(filepath, str(os.getcwd()) + '/' + 'failed/')
        os._exit(0)
    except IOError as e2:
        print('[-]' + str(os.path.basename(filepath)) +
              ' Cannot catch the number :')
        print('[-]' + str(os.path.basename(filepath)) + ' :', e2)
        print('[-]Move ' + os.path.basename(filepath) + ' to failed folder')
        shutil.move(filepath, str(os.getcwd()) + '/' + 'failed/')
        os._exit(0)
    try:

        # ================================================网站规则添加开始================================================

        try:  #添加 需要 正则表达式的规则
            #=======================javbus.py=======================
            if re.search('^\d{5,}', file_number).group() in filename:
                json_data = json.loads(javbus.main_uncensored(file_number))
        except:  #添加 无需 正则表达式的规则
            # ====================fc2fans_club.py===================
            if 'fc2' in filename:
                json_data = json.loads(
                    fc2fans_club.main(file_number.strip('fc2_').strip('fc2-')))
            elif 'FC2' in filename:
                json_data = json.loads(
                    fc2fans_club.main(file_number.strip('FC2_').strip('FC2-')))

            #========================siro.py========================
            elif 'siro' in filename:
                json_data = json.loads(siro.main(file_number))
            elif 'SIRO' in filename:
                json_data = json.loads(siro.main(file_number))
            elif '259luxu' in filename:
                json_data = json.loads(siro.main(file_number))
            elif '259LUXU' in filename:
                json_data = json.loads(siro.main(file_number))
            elif '300MAAN' in filename:
                json_data = json.loads(siro.main(file_number))
            elif '300maan' in filename:
                json_data = json.loads(siro.main(file_number))
            elif '326SCP' in filename:
                json_data = json.loads(siro.main(file_number))
            elif '326scp' in filename:
                json_data = json.loads(siro.main(file_number))
            elif '326URF' in filename:
                json_data = json.loads(siro.main(file_number))
            elif '326urf' in filename:
                json_data = json.loads(siro.main(file_number))

            #=======================javbus.py=======================
            else:
                json_data = json.loads(javbus.main(file_number))


#================================================网站规则添加结束================================================

        title = json_data['title']
        studio = json_data['studio']
        year = json_data['year']
        outline = json_data['outline']
        runtime = json_data['runtime']
        director = json_data['director']
        actor_list = str(json_data['actor']).strip("[ ]").replace(
            "'", '').replace(" ", '').split(',')  #字符串转列表
        release = json_data['release']
        number = json_data['number']
        cover = json_data['cover']
        imagecut = json_data['imagecut']
        tag = str(json_data['tag']).strip("[ ]").replace("'", '').replace(
            " ", '').split(',')  #字符串转列表
        actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '')

        naming_rule = eval(config['Name_Rule']['naming_rule'])
        location_rule = eval(config['Name_Rule']['location_rule'])
    except IOError as e:
        print('[-]' + str(e))
        print('[-]Move ' + filename + ' to failed folder')
        shutil.move(filepath, str(os.getcwd()) + '/' + 'failed/')
        os._exit(0)

    except Exception as e:
        print('[-]' + str(e))
        print('[-]Move ' + filename + ' to failed folder')
        shutil.move(filepath, str(os.getcwd()) + '/' + 'failed/')
        os._exit(0)
Example #5
0
File: core.py Project: zhiyue/AVDC
def getDataFromJSON(file_number, config, mode):  # 从JSON返回元数据
    # ================================================网站规则添加开始================================================
    json_data = {}
    if mode == 1:  # 从全部网站刮削
        # =======================================================================无码抓取:111111-111,n1111,HEYZO-1111
        if re.match('^\d{4,}', file_number) or re.match('n\d{4}', file_number) or 'HEYZO' in file_number.upper():
            json_data = json.loads(javbus.main_uncensored(file_number))
            if getDataState(json_data) == 0:
                json_data = json.loads(javdb.main(file_number))
            if getDataState(json_data) == 0:
                json_data = json.loads(avsox.main(file_number))
        # =======================================================================259LUXU-1111
        elif re.match('\d+\D+', file_number):
            json_data = json.loads(siro.main(file_number))
            if getDataState(json_data) == 0:
                json_data = json.loads(javbus.main(file_number))
            if getDataState(json_data) == 0:
                json_data = json.loads(javdb.main(file_number))
        # =======================================================================FC2-111111
        elif 'FC2' in file_number.upper():
            json_data = json.loads(fc2fans_club.main(
                file_number.replace('fc2-', '').replace('fc2_', '').replace('FC2-', '').replace('fc2_', '')))
            if getDataState(json_data) == 0:
                json_data = json.loads(javdb.main(file_number))
        # =======================================================================SIRO-111
        elif 'SIRO' in file_number.upper():
            json_data = json.loads(siro.main(file_number))
            if getDataState(json_data) == 0:
                json_data = json.loads(javdb.main(file_number))
        # =======================================================================ssni00321
        elif re.match('\D{2,}00\d{3,}', file_number):
            json_data = json.loads(fanza.main(file_number))
        # =======================================================================MIDE-139
        else:
            json_data = json.loads(javbus.main(file_number))
            if getDataState(json_data) == 0:
                json_data = json.loads(avsox.main(file_number))
            if getDataState(json_data) == 0:
                json_data = json.loads(javdb.main(file_number))
    elif mode != 6 and re.match('\D{2,}00\d{3,}', file_number):
        json_data = {
            'title': '',
            'actor': '',
            'website': '',
        }
    elif mode == 2:  # 仅从javdb
        json_data = json.loads(javdb.main(file_number))
    elif mode == 3:  # 仅从javbus
        if re.match('^\d{5,}', file_number) or re.match('n\d{4}', file_number) or 'HEYZO' in file_number.upper():
            json_data = json.loads(javbus.main_uncensored(file_number))
        else:
            json_data = json.loads(javbus.main(file_number))
    elif mode == 4:  # 仅从avsox
        json_data = json.loads(avsox.main(file_number))
    elif mode == 5:  # 仅从fc2club
        json_data = json.loads(fc2fans_club.main(file_number))
    elif mode == 6:  # 仅从fanza
        json_data = json.loads(fanza.main(file_number))
    elif mode == 7:  # 仅从siro
        json_data = json.loads(siro.main(file_number))

    # ================================================网站规则添加结束================================================
    # print(json_data)
    # ======================================超时或未找到
    if json_data['website'] == 'timeout':
        return json_data
    elif json_data['title'] == '':
        return json_data
    title = json_data['title']
    number = json_data['number'].replace('_', '-')
    actor_list = str(json_data['actor']).strip("[ ]").replace("'", '').split(',')  # 字符串转列表
    release = json_data['release']
    try:
        cover_small = json_data['cover_small']
    except:
        cover_small = ''
    tag = str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(',')  # 字符串转列表 @
    actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '')

    # ====================处理异常字符====================== #\/:*?"<>|
    title = title.replace('\\', '')
    title = title.replace('/', '')
    title = title.replace(':', '')
    title = title.replace('*', '')
    title = title.replace('?', '')
    title = title.replace('"', '')
    title = title.replace('<', '')
    title = title.replace('>', '')
    title = title.replace('|', '')
    title = title.replace(' ', '')
    release = release.replace('/', '-')
    tmpArr = cover_small.split(',')
    if len(tmpArr) > 0:
        cover_small = tmpArr[0].strip('\"').strip('\'')
    # ====================处理异常字符 END================== #\/:*?"<>|

    naming_rule = config['Name_Rule']['naming_rule']
    location_rule = config['Name_Rule']['location_rule']

    # 返回处理后的json_data
    json_data['title'] = title
    json_data['number'] = number
    json_data['actor'] = actor
    json_data['release'] = release
    json_data['cover_small'] = cover_small
    json_data['tag'] = tag
    json_data['naming_rule'] = naming_rule
    json_data['location_rule'] = location_rule
    return json_data