├── readme ├── This is readms.md's images folder ├── emby.png ├── tool.png ├── 主页面.gif ├── about.png ├── readme1.PNG ├── readme2.PNG ├── readme3.PNG ├── readme4.PNG ├── setting.png ├── single.gif ├── emby_each.png ├── flow_chart2.png ├── main_window.png └── tree-jav-output.png ├── AVDC-ico.png ├── py-require.txt ├── update_check.json ├── .idea ├── misc.xml ├── vcs.xml ├── modules.xml ├── AVDC.iml └── workspace.xml ├── config.ini ├── .gitignore ├── AV_Data_Capture.py ├── ADC_function.py ├── fc2fans_club.py ├── avsox.py ├── fanza.py ├── siro.py ├── core.py ├── javbus.py ├── README.md ├── javdb.py ├── LICENSE └── AVDC_Main.py /readme/This is readms.md's images folder: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /AVDC-ico.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/674316/AVDC/HEAD/AVDC-ico.png -------------------------------------------------------------------------------- /readme/emby.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/674316/AVDC/HEAD/readme/emby.png -------------------------------------------------------------------------------- /readme/tool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/674316/AVDC/HEAD/readme/tool.png -------------------------------------------------------------------------------- /readme/主页面.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/674316/AVDC/HEAD/readme/主页面.gif -------------------------------------------------------------------------------- /readme/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/674316/AVDC/HEAD/readme/about.png -------------------------------------------------------------------------------- /readme/readme1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/674316/AVDC/HEAD/readme/readme1.PNG -------------------------------------------------------------------------------- /readme/readme2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/674316/AVDC/HEAD/readme/readme2.PNG -------------------------------------------------------------------------------- /readme/readme3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/674316/AVDC/HEAD/readme/readme3.PNG -------------------------------------------------------------------------------- /readme/readme4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/674316/AVDC/HEAD/readme/readme4.PNG -------------------------------------------------------------------------------- /readme/setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/674316/AVDC/HEAD/readme/setting.png -------------------------------------------------------------------------------- /readme/single.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/674316/AVDC/HEAD/readme/single.gif -------------------------------------------------------------------------------- /py-require.txt: -------------------------------------------------------------------------------- 1 | lxml 2 | pyqt5 3 | pyqt5-tools 4 | pillow 5 | bs4 6 | pyquery 7 | requests -------------------------------------------------------------------------------- /readme/emby_each.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/674316/AVDC/HEAD/readme/emby_each.png -------------------------------------------------------------------------------- /readme/flow_chart2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/674316/AVDC/HEAD/readme/flow_chart2.png -------------------------------------------------------------------------------- /readme/main_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/674316/AVDC/HEAD/readme/main_window.png -------------------------------------------------------------------------------- /readme/tree-jav-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/674316/AVDC/HEAD/readme/tree-jav-output.png -------------------------------------------------------------------------------- /update_check.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "3.61", 3 | "version_show":"3.61", 4 | "download": "https://github.com/moyy996/AVDC/releases" 5 | } 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/AVDC.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | -------------------------------------------------------------------------------- /config.ini: -------------------------------------------------------------------------------- 1 | [common] 2 | main_mode = 1 3 | failed_output_folder = failed 4 | success_output_folder = JAV_output 5 | soft_link = 0 6 | website = all 7 | #all or javdb 8 | 9 | [proxy] 10 | proxy = 11 | timeout = 7 12 | retry = 3 13 | 14 | [Name_Rule] 15 | location_rule = actor/number-【title】-release 16 | naming_rule = number-【title】 17 | 18 | [update] 19 | update_check = 1 20 | 21 | [media] 22 | media_warehouse = emby 23 | #emby or plex or kodi ,emby = jellyfin 24 | 25 | [escape] 26 | literals = \() 27 | folders = failed,JAV_output 28 | 29 | [debug_mode] 30 | switch = 0 31 | 32 | [emby] 33 | emby_url = localhost:8096 34 | api_key = 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /AV_Data_Capture.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | from core import * 6 | 7 | 8 | def movie_lists(escape_folder): 9 | if escape_folder != '': 10 | escape_folder = re.split('[,,]', escape_folder) 11 | total = [] 12 | file_type = ['.mp4', '.avi', '.rmvb', '.wmv', '.mov', '.mkv', '.flv', '.ts', '.MP4', '.AVI', '.RMVB', '.WMV', 13 | '.MOV', '.MKV', '.FLV', '.TS', ] 14 | file_root = os.getcwd() 15 | for root, dirs, files in os.walk(file_root): 16 | if escape_folder != '': 17 | flag_escape = 0 18 | for folder in escape_folder: 19 | if folder in root: 20 | flag_escape = 1 21 | break 22 | if flag_escape == 1: 23 | continue 24 | for f in files: 25 | if os.path.splitext(f)[1] in file_type: 26 | path = root + '/' + f 27 | path = path.replace(file_root, '.') 28 | path = path.replace("\\\\", "/").replace("\\", "/") 29 | total.append(path) 30 | return total 31 | 32 | 33 | def getNumber(filepath): 34 | filepath = filepath.replace('-C.', '.').replace('-c.', '.') 35 | filepath = os.path.splitext(filepath.split('/')[-1])[0] 36 | filepath = filepath.replace("_", "-") 37 | part = '' 38 | if re.search('-CD\d+', filepath): 39 | part = re.findall('-CD\d+', filepath)[0] 40 | if re.search('-cd\d+', filepath): 41 | part = re.findall('-cd\d+', filepath)[0] 42 | filepath.strip('22-sht.me').strip('-HD').strip('-hd') 43 | filepath = filepath.replace(part, '') 44 | filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath)) # 去除文件名中时间 45 | if '-' in filename or '_' in filename: # 普通提取番号 主要处理包含减号-和_的番号 46 | if 'FC2' or 'fc2' in filename: 47 | filename = filename.replace('-PPV', '').replace('PPV-', '').replace('-ppv', '').replace('ppv-', '') 48 | if re.search('\w+-\d+', filename): # 提取类似mkbd-120番号 49 | file_number = re.search('\w+-\d+', filename).group() 50 | elif re.search('\w+-\w\d+', filename): # 提取类似mkbd-s120番号 51 | file_number = re.search('\w+-\w\d+', filename).group() 52 | elif re.search('\d+-\w+', filename): # 提取类似 111111-MMMM 番号 53 | file_number = re.search('\d+-\w+', filename).group() 54 | elif re.search('\d+-\d+', filename): # 提取类似 111111-000 番号 55 | file_number = re.search('\d+-\d+', filename).group() 56 | else: 57 | file_number = filename 58 | return file_number 59 | else: # 提取不含减号-的番号,FANZA CID 保留ssni00644,将MIDE139改成MIDE-139 60 | try: 61 | file_number = os.path.splitext(filepath.split('/')[-1])[0] 62 | find_num = re.findall(r'\d+', file_number)[0] 63 | find_char = re.findall(r'\D+', file_number)[0] 64 | if len(find_num) <= 4 and len(find_char) > 1: 65 | file_number = find_char + '-' + find_num 66 | return file_number 67 | except: 68 | return os.path.splitext(filepath.split('/')[-1])[0] 69 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 14 | 15 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 1580628575930 50 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /ADC_function.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import requests 5 | from configparser import ConfigParser 6 | from lxml import etree 7 | 8 | 9 | # sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True) 10 | # sys.setdefaultencoding('utf-8') 11 | 12 | def save_config(json_config): 13 | # json_config = json.loads(json_config) 14 | with open("config.ini", "wt", encoding='UTF-8') as code: 15 | print("[common]", file=code) 16 | print("main_mode = " + str(json_config['main_mode']), file=code) 17 | print("failed_output_folder = " + json_config['failed_output_folder'], file=code) 18 | print("success_output_folder = " + json_config['success_output_folder'], file=code) 19 | print("soft_link = " + str(json_config['soft_link']), file=code) 20 | print("website = " + json_config['website'], file=code) 21 | print("#all or javdb", file=code) 22 | print("", file=code) 23 | print("[proxy]", file=code) 24 | print("proxy = " + json_config['proxy'], file=code) 25 | print("timeout = " + str(json_config['timeout']), file=code) 26 | print("retry = " + str(json_config['retry']), file=code) 27 | print("", file=code) 28 | print("[Name_Rule]", file=code) 29 | print("location_rule = " + json_config['location_rule'], file=code) 30 | print("naming_rule = " + json_config['naming_rule'], file=code) 31 | print("", file=code) 32 | print("[update]", file=code) 33 | print("update_check = " + str(json_config['update_check']), file=code) 34 | print("", file=code) 35 | print("[media]", file=code) 36 | print("media_warehouse = " + json_config['media_warehouse'], file=code) 37 | print("#emby or plex or kodi ,emby = jellyfin", file=code) 38 | print("", file=code) 39 | print("[escape]", file=code) 40 | print("literals = " + json_config['literals'], file=code) 41 | print("folders = " + json_config['folders'], file=code) 42 | print("", file=code) 43 | print("[debug_mode]", file=code) 44 | print("switch = " + str(json_config['switch_debug']), file=code) 45 | print("", file=code) 46 | print("[emby]", file=code) 47 | print("emby_url = " + json_config['emby_url'], file=code) 48 | print("api_key = " + json_config['api_key'], file=code) 49 | code.close() 50 | 51 | 52 | def getDataState(json_data): # 元数据获取失败检测 53 | if json_data['title'] == '' or json_data['title'] == 'None' or json_data['title'] == 'null': 54 | return 0 55 | else: 56 | return 1 57 | 58 | 59 | def ReadMediaWarehouse(config): 60 | return config['media']['media_warehouse'] 61 | 62 | 63 | def UpdateCheckSwitch(check): 64 | if check == 1: 65 | return '1' 66 | else: 67 | return '0' 68 | 69 | 70 | def getXpathSingle(htmlcode, xpath): 71 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 72 | result1 = str(html.xpath(xpath)).strip(" ['']") 73 | return result1 74 | 75 | 76 | def get_html(url, cookies=None): # 网页请求核心 77 | config_file = 'config.ini' 78 | config = ConfigParser() 79 | config.read(config_file, encoding='UTF-8') 80 | retry_count = 0 81 | proxy = {} 82 | timeout = 0 83 | try: 84 | proxy = config['proxy']['proxy'] 85 | timeout = int(config['proxy']['timeout']) 86 | retry_count = int(config['proxy']['retry']) 87 | except: 88 | print('[-]Proxy config error! Please check the config.') 89 | i = 0 90 | while i < retry_count: 91 | try: 92 | if not str(config['proxy']['proxy']) == '': 93 | proxies = {"http": "http://" + proxy, "https": "https://" + proxy} 94 | headers = { 95 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' 96 | 'Chrome/60.0.3100.0 Safari/537.36'} 97 | getweb = requests.get(str(url), headers=headers, timeout=timeout, proxies=proxies, cookies=cookies) 98 | getweb.encoding = 'utf-8' 99 | return getweb.text 100 | else: 101 | headers = { 102 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' 103 | 'Chrome/68.0.3440.106 Safari/537.36'} 104 | getweb = requests.get(str(url), headers=headers, timeout=timeout, cookies=cookies) 105 | getweb.encoding = 'utf-8' 106 | return getweb.text 107 | except: 108 | i += 1 109 | print('[-]Connect retry ' + str(i) + '/' + str(retry_count)) 110 | print('[-]Connect Failed! Please check your Proxy or Network!') 111 | return 'ProxyError' 112 | -------------------------------------------------------------------------------- /fc2fans_club.py: -------------------------------------------------------------------------------- 1 | import re 2 | from lxml import etree # need install 3 | import json 4 | import ADC_function 5 | 6 | 7 | def getTitle(htmlcode): # 获取厂商 8 | # print(htmlcode) 9 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 10 | result = str(html.xpath('/html/body/div[2]/div/div[1]/h3/text()')).strip(" ['']") 11 | result2 = str(re.sub('\D{2}2-\d+', '', result)).replace(' ', '', 1) 12 | # print(result2) 13 | return result2 14 | 15 | 16 | def getActor(htmlcode): 17 | try: 18 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 19 | result = str(html.xpath('/html/body/div[2]/div/div[1]/h5[5]/a/text()')).strip(" ['']") 20 | return result 21 | except: 22 | return '' 23 | 24 | 25 | def getActorPhoto(actor): # //*[@id="star_qdt"]/li/a/img 26 | actor = actor.split('/') 27 | d = {} 28 | for i in actor: 29 | p = {i: ''} 30 | d.update(p) 31 | return d 32 | 33 | 34 | def getStudio(htmlcode): # 获取厂商 35 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 36 | result = str(html.xpath('/html/body/div[2]/div/div[1]/h5[3]/a[1]/text()')).strip(" ['']") 37 | return result 38 | 39 | 40 | def getNum(htmlcode): # 获取番号 41 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 42 | result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[1]/span[2]/text()')).strip(" ['']") 43 | # print(result) 44 | return result 45 | 46 | 47 | def getRelease(htmlcode2): # 48 | # a=ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id='+str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-")+'&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php') 49 | html = etree.fromstring(htmlcode2, etree.HTMLParser()) 50 | result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[2]/dl/dd[4]/text()')).strip( 51 | " ['']") 52 | return result 53 | 54 | 55 | def getCover(htmlcode, number, htmlcode2): # 获取厂商 # 56 | # a = ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id=' + str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-") + '&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php') 57 | html = etree.fromstring(htmlcode2, etree.HTMLParser()) 58 | result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[1]/a/img/@src')).strip(" ['']") 59 | if result == '': 60 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 61 | result2 = str(html.xpath('//*[@id="slider"]/ul[1]/li[1]/img/@src')).strip(" ['']") 62 | return 'https://fc2club.com' + result2 63 | return 'http:' + result 64 | 65 | 66 | def getOutline(htmlcode2): # 获取番号 # 67 | html = etree.fromstring(htmlcode2, etree.HTMLParser()) 68 | result = str(html.xpath('/html/body/div[1]/div[2]/div[2]/div[1]/div/article/section[4]/p/text()')).strip( 69 | " ['']").replace("\\n", '', 10000).replace("'", '', 10000).replace(', ,', '').strip(' ').replace('。,', ',') 70 | return result 71 | 72 | 73 | def getTag(htmlcode): # 获取番号 74 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 75 | result = str(html.xpath('/html/body/div[2]/div/div[1]/h5[4]/a/text()')) 76 | return result.strip(" ['']").replace("'", '').replace(' ', '') 77 | 78 | 79 | def getYear(release): 80 | try: 81 | result = re.search('\d{4}', release).group() 82 | return result 83 | except: 84 | return '' 85 | 86 | 87 | def main(number): 88 | htmlcode2 = ADC_function.get_html( 89 | 'http://adult.contents.fc2.com/article_search.php?id=' + number + '&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php') 90 | htmlcode = ADC_function.get_html('https://fc2club.com//html/FC2-' + number + '.html') 91 | actor = getActor(htmlcode) 92 | if len(actor) == 0: 93 | actor = 'FC2系列' 94 | try: 95 | dic = { 96 | 'title': getTitle(htmlcode).replace(' ', '-'), 97 | 'studio': getStudio(htmlcode), 98 | 'year': '', # str(re.search('\d{4}',getRelease(number)).group()), 99 | 'outline': getOutline(htmlcode2).replace('\n', ''), 100 | 'runtime': getYear(getRelease(htmlcode)), 101 | 'director': '', 102 | 'actor': actor.replace('/', ','), 103 | 'release': getRelease(number), 104 | 'number': 'FC2-' + number, 105 | 'cover': getCover(htmlcode, number, htmlcode2), 106 | 'imagecut': 0, 107 | 'label': '', 108 | 'tag': getTag(htmlcode), 109 | 'actor_photo': getActorPhoto(actor), 110 | 'website': 'https://fc2club.com//html/FC2-' + number + '.html', 111 | 'source': 'fc2fans_club.py', 112 | } 113 | except: 114 | if htmlcode2 == 'ProxyError': 115 | dic = { 116 | 'title': '', 117 | 'website': 'timeout', 118 | } 119 | else: 120 | dic = { 121 | 'title': '', 122 | 'website': '', 123 | } 124 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') 125 | return js 126 | 127 | # print(main('1251689')) 128 | -------------------------------------------------------------------------------- /avsox.py: -------------------------------------------------------------------------------- 1 | import re 2 | from lxml import etree 3 | import json 4 | from bs4 import BeautifulSoup 5 | from ADC_function import * 6 | 7 | 8 | def getActorPhoto(htmlcode): # //*[@id="star_qdt"]/li/a/img 9 | soup = BeautifulSoup(htmlcode, 'lxml') 10 | a = soup.find_all(attrs={'class': 'avatar-box'}) 11 | d = {} 12 | for i in a: 13 | l = i.img['src'] 14 | t = i.span.get_text() 15 | p2 = {t: l} 16 | d.update(p2) 17 | return d 18 | 19 | 20 | def getTitle(a): 21 | try: 22 | html = etree.fromstring(a, etree.HTMLParser()) 23 | result = str(html.xpath('/html/body/div[2]/h3/text()')).strip(" ['']") # [0] 24 | return result.replace('/', '').replace('_', '-') 25 | except: 26 | return '' 27 | 28 | 29 | def getActor(a): # //*[@id="center_column"]/div[2]/div[1]/div/table/tbody/tr[1]/td/text() 30 | soup = BeautifulSoup(a, 'lxml') 31 | a = soup.find_all(attrs={'class': 'avatar-box'}) 32 | d = [] 33 | for i in a: 34 | d.append(i.span.get_text()) 35 | return d 36 | 37 | 38 | def getStudio(a): 39 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 40 | result1 = str(html.xpath('//p[contains(text(),"制作商: ")]/following-sibling::p[1]/a/text()')).strip(" ['']").replace( 41 | "', '", ' ') 42 | return result1 43 | 44 | 45 | def getRuntime(a): 46 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 47 | result1 = str(html.xpath('//span[contains(text(),"长度:")]/../text()')).strip(" ['分钟']") 48 | return result1 49 | 50 | 51 | def getLabel(a): 52 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 53 | result1 = str(html.xpath('//p[contains(text(),"系列:")]/following-sibling::p[1]/a/text()')).strip(" ['']") 54 | return result1 55 | 56 | 57 | def getNum(a): 58 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 59 | result1 = str(html.xpath('//span[contains(text(),"识别码:")]/../span[2]/text()')).strip(" ['']").replace('_', '-') 60 | return result1 61 | 62 | 63 | def getYear(release): 64 | try: 65 | result = str(re.search('\d{4}', release).group()) 66 | return result 67 | except: 68 | return release 69 | 70 | 71 | def getRelease(a): 72 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 73 | result1 = str(html.xpath('//span[contains(text(),"发行时间:")]/../text()')).strip(" ['']") 74 | return result1 75 | 76 | 77 | def getCover(htmlcode): 78 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 79 | result = str(html.xpath('/html/body/div[2]/div[1]/div[1]/a/img/@src')).strip(" ['']") 80 | return result 81 | 82 | 83 | def getCover_small(htmlcode): 84 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 85 | result = html.xpath('//*[@id="waterfall"]/div/a/div[1]/img/@src') 86 | if len(result) > 1: 87 | result = result[0] 88 | else: 89 | result = str(result).strip(" ['']") 90 | 91 | return result 92 | 93 | 94 | def getTag(a): # 获取演员 95 | soup = BeautifulSoup(a, 'lxml') 96 | a = soup.find_all(attrs={'class': 'genre'}) 97 | d = [] 98 | for i in a: 99 | d.append(i.get_text()) 100 | return d 101 | 102 | 103 | def main(number): 104 | a = get_html('https://avsox.host/cn/search/' + number) 105 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 106 | result1 = str(html.xpath('//*[@id="waterfall"]/div/a/@href')).strip(" ['']") 107 | if result1 == '' or result1 == 'null' or result1 == 'None': 108 | a = get_html('https://avsox.host/cn/search/' + number.replace('-', '_')) 109 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 110 | result1 = str(html.xpath('//*[@id="waterfall"]/div/a/@href')).strip(" ['']") 111 | if result1 == '' or result1 == 'null' or result1 == 'None': 112 | a = get_html('https://avsox.host/cn/search/' + number.replace('_', '')) 113 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 114 | result1 = str(html.xpath('//*[@id="waterfall"]/div/a/@href')).strip(" ['']") 115 | web = get_html(result1) 116 | soup = BeautifulSoup(web, 'lxml') 117 | info = str(soup.find(attrs={'class': 'row movie'})) 118 | try: 119 | dic = { 120 | 'actor': getActor(web), 121 | 'title': getTitle(web).strip(getNum(web)).strip().replace(' ', '-'), 122 | 'studio': getStudio(info), 123 | 'outline': '', # 124 | 'runtime': getRuntime(info), 125 | 'director': '', # 126 | 'release': getRelease(info), 127 | 'number': getNum(info), 128 | 'cover': getCover(web), 129 | 'cover_small': getCover_small(a), 130 | 'imagecut': 3, 131 | 'tag': getTag(web), 132 | 'label': getLabel(info), 133 | 'year': getYear(getRelease(info)), # str(re.search('\d{4}',getRelease(a)).group()), 134 | 'actor_photo': getActorPhoto(web), 135 | 'website': result1, 136 | 'source': 'avsox.py', 137 | } 138 | except: 139 | if a == 'ProxyError': 140 | dic = { 141 | 'title': '', 142 | 'website': 'timeout', 143 | } 144 | else: 145 | dic = { 146 | 'title': '', 147 | 'website': '', 148 | } 149 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') 150 | return js 151 | 152 | # print(main('051119-917')) 153 | -------------------------------------------------------------------------------- /fanza.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | import re 4 | from lxml import etree 5 | import json 6 | from ADC_function import * 7 | 8 | 9 | # import sys 10 | # import io 11 | # sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True) 12 | 13 | def getTitle(a): 14 | html = etree.fromstring(a, etree.HTMLParser()) 15 | result = html.xpath('//*[@id="title"]/text()')[0] 16 | return result 17 | 18 | 19 | def getActor(a): # //*[@id="center_column"]/div[2]/div[1]/div/table/tbody/tr[1]/td/text() 20 | html = etree.fromstring(a, etree.HTMLParser()) 21 | result = str(html.xpath("//td[contains(text(),'出演者')]/following-sibling::td/span/a/text()")).strip(" ['']").replace( 22 | "', '", ',') 23 | return result 24 | 25 | 26 | def getActorPhoto(actor): # //*[@id="star_qdt"]/li/a/img 27 | actor = actor.split(',') 28 | d = {} 29 | for i in actor: 30 | if ',' not in i: 31 | p = {i: ''} 32 | d.update(p) 33 | return d 34 | 35 | 36 | def getStudio(a): 37 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 38 | try: 39 | result1 = html.xpath("//td[contains(text(),'メーカー')]/following-sibling::td/a/text()")[0] 40 | except: 41 | result1 = html.xpath("//td[contains(text(),'メーカー')]/following-sibling::td/text()")[0] 42 | return result1 43 | 44 | 45 | def getRuntime(a): 46 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 47 | result1 = html.xpath("//td[contains(text(),'収録時間')]/following-sibling::td/text()")[0] 48 | return re.search('\d+', str(result1)).group() 49 | 50 | 51 | def getLabel(a): 52 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 53 | try: 54 | result1 = html.xpath("//td[contains(text(),'レーベル:')]/following-sibling::td/a/text()")[0] 55 | except: 56 | result1 = html.xpath("//td[contains(text(),'レーベル:')]/following-sibling::td/text()")[0] 57 | return result1 58 | 59 | 60 | def getNum(a): 61 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 62 | try: 63 | result1 = html.xpath("//td[contains(text(),'品番:')]/following-sibling::td/a/text()")[0] 64 | except: 65 | result1 = html.xpath("//td[contains(text(),'品番:')]/following-sibling::td/text()")[0] 66 | return result1 67 | 68 | 69 | def getYear(getRelease): 70 | try: 71 | result = str(re.search('\d{4}', getRelease).group()) 72 | return result 73 | except: 74 | return getRelease 75 | 76 | 77 | def getRelease(a): 78 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 79 | try: 80 | result1 = html.xpath("//td[contains(text(),'発売日:')]/following-sibling::td/a/text()")[0].lstrip('\n') 81 | except: 82 | result1 = html.xpath("//td[contains(text(),'発売日:')]/following-sibling::td/text()")[0].lstrip('\n') 83 | return result1 84 | 85 | 86 | def getTag(a): 87 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 88 | try: 89 | result1 = str(html.xpath("//td[contains(text(),'ジャンル:')]/following-sibling::td/a/text()")).strip(" ['']") 90 | except: 91 | result1 = str(html.xpath("//td[contains(text(),'ジャンル:')]/following-sibling::td/text()")).strip(" ['']") 92 | return result1.replace("', '", ",") 93 | 94 | 95 | def getCover(htmlcode, number): 96 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 97 | result = html.xpath('//*[@id="' + number + '"]/@href')[0] 98 | return result 99 | 100 | 101 | def getDirector(a): 102 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 103 | try: 104 | result1 = html.xpath("//td[contains(text(),'監督:')]/following-sibling::td/a/text()")[0] 105 | except: 106 | result1 = html.xpath("//td[contains(text(),'監督:')]/following-sibling::td/text()")[0] 107 | return result1 108 | 109 | 110 | def getOutline(htmlcode): 111 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 112 | result = str(html.xpath("//div[@class='mg-b20 lh4']/text()")[0]).replace('\n', '') 113 | return result 114 | 115 | 116 | def main(number): 117 | htmlcode = get_html('https://www.dmm.co.jp/digital/videoa/-/detail/=/cid=' + number) 118 | url = 'https://www.dmm.co.jp/digital/videoa/-/detail/=/cid=' + number 119 | if '404 Not Found' in htmlcode: 120 | htmlcode = get_html('https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=' + number) 121 | url = 'https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=' + number 122 | try: 123 | actor = getActor(htmlcode) 124 | dic = { 125 | 'title': getTitle(htmlcode).strip(getActor(htmlcode)), 126 | 'studio': getStudio(htmlcode), 127 | 'outline': getOutline(htmlcode).replace('\n', ''), 128 | 'runtime': getRuntime(htmlcode), 129 | 'director': getDirector(htmlcode), 130 | 'actor': actor, 131 | 'release': getRelease(htmlcode), 132 | 'number': getNum(htmlcode), 133 | 'cover': getCover(htmlcode, number), 134 | 'imagecut': 1, 135 | 'tag': getTag(htmlcode), 136 | 'label': getLabel(htmlcode), 137 | 'year': getYear(getRelease(htmlcode)), # str(re.search('\d{4}',getRelease(a)).group()), 138 | 'actor_photo': getActorPhoto(actor), 139 | 'website': url, 140 | 'source': 'siro.py', 141 | } 142 | except: 143 | if htmlcode == 'ProxyError': 144 | dic = { 145 | 'title': '', 146 | 'website': 'timeout', 147 | } 148 | else: 149 | dic = { 150 | 'title': '', 151 | 'website': '', 152 | } 153 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':')) # .encode('UTF-8') 154 | return js 155 | 156 | # main('DV-1562') 157 | # input("[+][+]Press enter key exit, you can check the error messge before you exit.\n[+][+]按回车键结束,你可以在结束之前查看和错误信息。") 158 | # print(main('ssni00684')) 159 | -------------------------------------------------------------------------------- /siro.py: -------------------------------------------------------------------------------- 1 | import re 2 | from lxml import etree 3 | import json 4 | from bs4 import BeautifulSoup 5 | from ADC_function import * 6 | 7 | 8 | def getTitle(a): 9 | try: 10 | html = etree.fromstring(a, etree.HTMLParser()) 11 | result = str(html.xpath('//*[@id="center_column"]/div[1]/h1/text()')).strip(" ['']") 12 | return result.replace('/', ',') 13 | except: 14 | return '' 15 | 16 | 17 | def getActor(a): # //*[@id="center_column"]/div[2]/div[1]/div/table/tbody/tr[1]/td/text() 18 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 19 | result1 = str(html.xpath('//th[contains(text(),"出演:")]/../td/a/text()')).strip(" ['']").strip('\\n ').strip( 20 | '\\n') 21 | result2 = str(html.xpath('//th[contains(text(),"出演:")]/../td/text()')).strip(" ['']").strip('\\n ').strip('\\n') 22 | return str(result1 + result2).strip('+').replace("', '", '').replace('"', '').replace('/', ',') 23 | 24 | 25 | def getActorPhoto(actor): # //*[@id="star_qdt"]/li/a/img 26 | d = {} 27 | for i in actor: 28 | if ',' not in i or ')' in i: 29 | p = {i: ''} 30 | d.update(p) 31 | return d 32 | 33 | 34 | def getStudio(a): 35 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 36 | result1 = str(html.xpath('//th[contains(text(),"メーカー:")]/../td/a/text()')).strip(" ['']").strip('\\n ').strip( 37 | '\\n') 38 | result2 = str(html.xpath('//th[contains(text(),"メーカー:")]/../td/text()')).strip(" ['']").strip('\\n ').strip( 39 | '\\n') 40 | return str(result1 + result2).strip('+').replace("', '", '').replace('"', '') 41 | 42 | 43 | def getRuntime(a): 44 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 45 | result1 = str(html.xpath('//th[contains(text(),"収録時間:")]/../td/a/text()')).strip(" ['']").strip('\\n ').strip( 46 | '\\n') 47 | result2 = str(html.xpath('//th[contains(text(),"収録時間:")]/../td/text()')).strip(" ['']").strip('\\n ').strip( 48 | '\\n') 49 | return str(result1 + result2).strip('+').rstrip('mi') 50 | 51 | 52 | def getLabel(a): 53 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 54 | result1 = str(html.xpath('//th[contains(text(),"シリーズ:")]/../td/a/text()')).strip(" ['']").strip('\\n ').strip( 55 | '\\n') 56 | result2 = str(html.xpath('//th[contains(text(),"シリーズ:")]/../td/text()')).strip(" ['']").strip('\\n ').strip( 57 | '\\n') 58 | return str(result1 + result2).strip('+').replace("', '", '').replace('"', '') 59 | 60 | 61 | def getNum(a): 62 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 63 | result1 = str(html.xpath('//th[contains(text(),"品番:")]/../td/a/text()')).strip(" ['']").strip('\\n ').strip( 64 | '\\n') 65 | result2 = str(html.xpath('//th[contains(text(),"品番:")]/../td/text()')).strip(" ['']").strip('\\n ').strip( 66 | '\\n') 67 | return str(result1 + result2).strip('+') 68 | 69 | 70 | def getYear(getRelease): 71 | try: 72 | result = str(re.search('\d{4}', getRelease).group()) 73 | return result 74 | except: 75 | return getRelease 76 | 77 | 78 | def getRelease(a): 79 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 80 | result1 = str(html.xpath('//th[contains(text(),"配信開始日:")]/../td/a/text()')).strip(" ['']").strip('\\n ').strip( 81 | '\\n') 82 | result2 = str(html.xpath('//th[contains(text(),"配信開始日:")]/../td/text()')).strip(" ['']").strip('\\n ').strip( 83 | '\\n') 84 | return str(result1 + result2).strip('+') 85 | 86 | 87 | def getTag(a): 88 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 89 | result1 = str(html.xpath('//th[contains(text(),"ジャンル:")]/../td/a/text()')).strip(" ['']").strip('\\n ').strip( 90 | '\\n') 91 | result2 = str(html.xpath('//th[contains(text(),"ジャンル:")]/../td/text()')).strip(" ['']").strip('\\n ').strip( 92 | '\\n') 93 | return str(result1 + result2).strip('+').replace("', '\\n", ",").replace("', '", "").replace('"', '') 94 | 95 | 96 | def getCover(htmlcode): 97 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 98 | result = str(html.xpath('//*[@id="center_column"]/div[1]/div[1]/div/div/h2/img/@src')).strip(" ['']") 99 | # /html/body/div[2]/article[2]/div[1]/div[1]/div/div/h2/img/@src 100 | return result 101 | 102 | 103 | def getOutline(htmlcode): 104 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 105 | result = str(html.xpath('//*[@id="introduction"]/dd/p[1]/text()')).strip(" ['']") 106 | return result 107 | 108 | 109 | def main(number2): 110 | number = number2.upper() 111 | htmlcode = str( 112 | get_html('https://www.mgstage.com/product/product_detail/' + str(number) + '/', cookies={'adc': '1'})) 113 | soup = BeautifulSoup(htmlcode, 'lxml') 114 | a = str(soup.find(attrs={'class': 'detail_data'})).replace('\n ', 115 | '').replace(' ', 116 | '').replace('\n ', 117 | '').replace( 118 | '\n ', '') 119 | try: 120 | actor = getActor(a).replace(' ', '') 121 | dic = { 122 | 'title': getTitle(htmlcode).replace("\\n", '').replace(' ', ''), 123 | 'studio': getStudio(a), 124 | 'outline': getOutline(htmlcode).replace('\n', ''), 125 | 'runtime': getRuntime(a), 126 | 'director': '', 127 | 'actor': actor, 128 | 'release': getRelease(a), 129 | 'number': getNum(a), 130 | 'cover': getCover(htmlcode), 131 | 'imagecut': 0, 132 | 'tag': getTag(a), 133 | 'label': getLabel(a).strip(','), 134 | 'year': getYear(getRelease(a)), # str(re.search('\d{4}',getRelease(a)).group()), 135 | 'actor_photo': getActorPhoto(actor.split(',')), 136 | 'website': 'https://www.mgstage.com/product/product_detail/' + str(number) + '/', 137 | 'source': 'siro.py', 138 | } 139 | except: 140 | if htmlcode == 'ProxyError': 141 | dic = { 142 | 'title': '', 143 | 'website': 'timeout', 144 | } 145 | else: 146 | dic = { 147 | 'title': '', 148 | 'website': '', 149 | } 150 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') 151 | return js 152 | 153 | # print(main('300MIUM-382')) 154 | -------------------------------------------------------------------------------- /core.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import re 4 | import shutil 5 | import json 6 | from ADC_function import * 7 | import fc2fans_club 8 | import siro 9 | import avsox 10 | import javbus 11 | import javdb 12 | import fanza 13 | 14 | 15 | # =====================本地文件处理=========================== 16 | 17 | def escapePath(path, Config): # Remove escape literals 18 | escapeLiterals = Config['escape']['literals'] 19 | backslash = '\\' 20 | for literal in escapeLiterals: 21 | path = path.replace(backslash + literal, '') 22 | return path 23 | 24 | 25 | def getDataFromJSON(file_number, config, mode): # 从JSON返回元数据 26 | # ================================================网站规则添加开始================================================ 27 | json_data = {} 28 | if mode == 1: # 从全部网站刮削 29 | # =======================================================================无码抓取:111111-111,n1111,HEYZO-1111 30 | if re.match('^\d{4,}', file_number) or re.match('n\d{4}', file_number) or 'HEYZO' in file_number.upper(): 31 | json_data = json.loads(javbus.main_uncensored(file_number)) 32 | if getDataState(json_data) == 0: 33 | json_data = json.loads(javdb.main(file_number)) 34 | if getDataState(json_data) == 0: 35 | json_data = json.loads(avsox.main(file_number)) 36 | # =======================================================================259LUXU-1111 37 | elif re.match('\d+\D+', file_number): 38 | json_data = json.loads(siro.main(file_number)) 39 | if getDataState(json_data) == 0: 40 | json_data = json.loads(javbus.main(file_number)) 41 | if getDataState(json_data) == 0: 42 | json_data = json.loads(javdb.main(file_number)) 43 | # =======================================================================FC2-111111 44 | elif 'FC2' in file_number.upper(): 45 | json_data = json.loads(fc2fans_club.main( 46 | file_number.replace('fc2-', '').replace('fc2_', '').replace('FC2-', '').replace('fc2_', ''))) 47 | if getDataState(json_data) == 0: 48 | json_data = json.loads(javdb.main(file_number)) 49 | # =======================================================================SIRO-111 50 | elif 'SIRO' in file_number.upper(): 51 | json_data = json.loads(siro.main(file_number)) 52 | if getDataState(json_data) == 0: 53 | json_data = json.loads(javdb.main(file_number)) 54 | # =======================================================================ssni00321 55 | elif re.match('\D{2,}00\d{3,}', file_number): 56 | json_data = json.loads(fanza.main(file_number)) 57 | # =======================================================================MIDE-139 58 | else: 59 | json_data = json.loads(javbus.main(file_number)) 60 | if getDataState(json_data) == 0: 61 | json_data = json.loads(avsox.main(file_number)) 62 | if getDataState(json_data) == 0: 63 | json_data = json.loads(javdb.main(file_number)) 64 | elif mode != 6 and re.match('\D{2,}00\d{3,}', file_number): 65 | json_data = { 66 | 'title': '', 67 | 'actor': '', 68 | 'website': '', 69 | } 70 | elif mode == 2: # 仅从javdb 71 | json_data = json.loads(javdb.main(file_number)) 72 | elif mode == 3: # 仅从javbus 73 | if re.match('^\d{5,}', file_number) or re.match('n\d{4}', file_number) or 'HEYZO' in file_number.upper(): 74 | json_data = json.loads(javbus.main_uncensored(file_number)) 75 | else: 76 | json_data = json.loads(javbus.main(file_number)) 77 | elif mode == 4: # 仅从avsox 78 | json_data = json.loads(avsox.main(file_number)) 79 | elif mode == 5: # 仅从fc2club 80 | json_data = json.loads(fc2fans_club.main(file_number)) 81 | elif mode == 6: # 仅从fanza 82 | json_data = json.loads(fanza.main(file_number)) 83 | elif mode == 7: # 仅从siro 84 | json_data = json.loads(siro.main(file_number)) 85 | 86 | # ================================================网站规则添加结束================================================ 87 | # print(json_data) 88 | # ======================================超时或未找到 89 | if json_data['website'] == 'timeout': 90 | return json_data 91 | elif json_data['title'] == '': 92 | return json_data 93 | title = json_data['title'] 94 | number = json_data['number'].replace('_', '-') 95 | actor_list = str(json_data['actor']).strip("[ ]").replace("'", '').split(',') # 字符串转列表 96 | release = json_data['release'] 97 | try: 98 | cover_small = json_data['cover_small'] 99 | except: 100 | cover_small = '' 101 | tag = str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(',') # 字符串转列表 @ 102 | actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '') 103 | 104 | # ====================处理异常字符====================== #\/:*?"<>| 105 | title = title.replace('\\', '') 106 | title = title.replace('/', '') 107 | title = title.replace(':', '') 108 | title = title.replace('*', '') 109 | title = title.replace('?', '') 110 | title = title.replace('"', '') 111 | title = title.replace('<', '') 112 | title = title.replace('>', '') 113 | title = title.replace('|', '') 114 | title = title.replace(' ', '') 115 | release = release.replace('/', '-') 116 | tmpArr = cover_small.split(',') 117 | if len(tmpArr) > 0: 118 | cover_small = tmpArr[0].strip('\"').strip('\'') 119 | # ====================处理异常字符 END================== #\/:*?"<>| 120 | 121 | naming_rule = config['Name_Rule']['naming_rule'] 122 | location_rule = config['Name_Rule']['location_rule'] 123 | 124 | # 返回处理后的json_data 125 | json_data['title'] = title 126 | json_data['number'] = number 127 | json_data['actor'] = actor 128 | json_data['release'] = release 129 | json_data['cover_small'] = cover_small 130 | json_data['tag'] = tag 131 | json_data['naming_rule'] = naming_rule 132 | json_data['location_rule'] = location_rule 133 | return json_data 134 | 135 | 136 | def get_info(json_data): # 返回json里的数据 137 | for key, value in json_data.items(): 138 | if value == '': 139 | value = 'unknown' 140 | title = json_data['title'] 141 | studio = json_data['studio'] 142 | year = json_data['year'] 143 | outline = json_data['outline'] 144 | runtime = json_data['runtime'] 145 | director = json_data['director'] 146 | actor_photo = json_data['actor_photo'] 147 | actor = json_data['actor'] 148 | release = json_data['release'] 149 | tag = json_data['tag'] 150 | number = json_data['number'] 151 | cover = json_data['cover'] 152 | website = json_data['website'] 153 | label = json_data['label'] 154 | return title, studio, year, outline, runtime, director, actor_photo, actor, release, tag, number, cover, website, label 155 | -------------------------------------------------------------------------------- /javbus.py: -------------------------------------------------------------------------------- 1 | import re 2 | from pyquery import PyQuery as pq # need install 3 | from lxml import etree # need install 4 | from bs4 import BeautifulSoup # need install 5 | import json 6 | from ADC_function import * 7 | 8 | 9 | def getActorPhoto(htmlcode): # //*[@id="star_qdt"]/li/a/img 10 | soup = BeautifulSoup(htmlcode, 'lxml') 11 | a = soup.find_all(attrs={'class': 'star-name'}) 12 | d = {} 13 | for i in a: 14 | l = i.a['href'] 15 | t = i.get_text() 16 | html = etree.fromstring(get_html(l), etree.HTMLParser()) 17 | p = str(html.xpath('//*[@id="waterfall"]/div[1]/div/div[1]/img/@src')).strip(" ['']") 18 | p2 = {t: p} 19 | d.update(p2) 20 | return d 21 | 22 | 23 | def getTitle(htmlcode): # 获取标题 24 | doc = pq(htmlcode) 25 | title = str(doc('div.container h3').text()).replace(' ', '-') 26 | try: 27 | title2 = re.sub('n\d+-', '', title) 28 | return title2 29 | except: 30 | return title 31 | 32 | 33 | def getStudio(htmlcode): # 获取厂商 34 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 35 | result = str(html.xpath('//span[contains(text(),"製作商")]/following-sibling::a/text()')).strip(" ['']") 36 | return result 37 | 38 | 39 | def getYear(getRelease): # 获取年份 40 | try: 41 | result = str(re.search('\d{4}', getRelease).group()) 42 | return result 43 | except: 44 | return getRelease 45 | 46 | 47 | def getCover(htmlcode): # 获取封面链接 48 | doc = pq(htmlcode) 49 | image = doc('a.bigImage') 50 | return image.attr('href') 51 | 52 | 53 | def getRelease(htmlcode): # 获取出版日期 54 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 55 | result = str(html.xpath('//span[contains(text(),"發行日期")]/../text()')).strip(" ['']") 56 | return result 57 | 58 | 59 | def getRuntime(htmlcode): # 获取分钟 60 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 61 | result = str(html.xpath('//span[contains(text(),"長度")]/../text()')).strip(" ['']") 62 | return result 63 | 64 | 65 | def getActor(htmlcode): # 获取女优 66 | b = [] 67 | soup = BeautifulSoup(htmlcode, 'lxml') 68 | a = soup.find_all(attrs={'class': 'star-name'}) 69 | for i in a: 70 | b.append(i.get_text()) 71 | return b 72 | 73 | 74 | def getNum(htmlcode): # 获取番号 75 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 76 | result = str(html.xpath('//span[contains(text(),"識別碼")]/following-sibling::span/text()')).strip(" ['']") 77 | return result 78 | 79 | 80 | def getDirector(htmlcode): # 获取导演 81 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 82 | result = str(html.xpath('//span[contains(text(),"導演")]/following-sibling::a/text()')).strip(" ['']") 83 | return result 84 | 85 | 86 | def getOutline(htmlcode): # 获取简介 87 | doc = pq(htmlcode) 88 | result = str(doc('tr td div.mg-b20.lh4 p.mg-b20').text()) 89 | return result 90 | 91 | 92 | def getSerise(htmlcode): 93 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 94 | result = str(html.xpath('//span[contains(text(),"系列")]/following-sibling::a/text()')).strip(" ['']") 95 | return result 96 | 97 | 98 | def getCover_small(number): # 从avsox获取封面图 99 | htmlcode = get_html('https://avsox.host/cn/search/' + number) 100 | html = etree.fromstring(htmlcode, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 101 | result1 = str(html.xpath('//*[@id="waterfall"]/div/a/@href')).strip(" ['']") 102 | if result1 == '' or result1 == 'null' or result1 == 'None': 103 | htmlcode = get_html('https://avsox.host/cn/search/' + number.replace('-', '_')) 104 | html = etree.fromstring(htmlcode, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 105 | result1 = str(html.xpath('//*[@id="waterfall"]/div/a/@href')).strip(" ['']") 106 | if result1 == '' or result1 == 'null' or result1 == 'None': 107 | htmlcode = get_html('https://avsox.host/cn/search/' + number.replace('_', '')) 108 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 109 | result = html.xpath('//*[@id="waterfall"]/div/a/div[1]/img/@src') 110 | if len(result) > 1: 111 | result = result[0] 112 | else: 113 | result = str(result).strip(" ['']") 114 | return result 115 | 116 | 117 | def getTag(htmlcode): # 获取标签 118 | tag = [] 119 | soup = BeautifulSoup(htmlcode, 'lxml') 120 | a = soup.find_all(attrs={'class': 'genre'}) 121 | for i in a: 122 | if 'onmouseout' in str(i): 123 | continue 124 | tag.append(i.get_text()) 125 | return tag 126 | 127 | 128 | def main(number): 129 | htmlcode = get_html('https://www.javbus.com/' + number) 130 | try: 131 | dww_htmlcode = get_html("https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=" + number.replace("-", '')) 132 | except: 133 | dww_htmlcode = '' 134 | try: 135 | dic = { 136 | 'title': str(re.sub('\w+-\d+-', '', getTitle(htmlcode))), 137 | 'studio': getStudio(htmlcode), 138 | 'year': getYear(getRelease(htmlcode)), 139 | 'outline': getOutline(dww_htmlcode).replace('\n', ''), 140 | 'runtime': getRuntime(htmlcode), 141 | 'director': getDirector(htmlcode), 142 | 'actor': getActor(htmlcode), 143 | 'release': getRelease(htmlcode), 144 | 'number': getNum(htmlcode), 145 | 'cover': getCover(htmlcode), 146 | 'imagecut': 1, 147 | 'tag': getTag(htmlcode), 148 | 'label': getSerise(htmlcode), 149 | 'actor_photo': getActorPhoto(htmlcode), 150 | 'website': 'https://www.javbus.com/' + number, 151 | 'source': 'javbus.py', 152 | } 153 | except: 154 | if htmlcode == 'ProxyError': 155 | dic = { 156 | 'title': '', 157 | 'website': 'timeout', 158 | } 159 | else: 160 | dic = { 161 | 'title': '', 162 | 'website': '', 163 | } 164 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') 165 | return js 166 | 167 | 168 | def main_uncensored(number): 169 | htmlcode = get_html('https://www.javbus.com/' + number) 170 | if getTitle(htmlcode) == '': 171 | htmlcode = get_html('https://www.javbus.com/' + number.replace('-', '_')) 172 | try: 173 | dic = { 174 | 'title': str(re.sub('\w+-\d+-', '', getTitle(htmlcode))).replace(getNum(htmlcode) + '-', ''), 175 | 'studio': getStudio(htmlcode), 176 | 'year': getYear(getRelease(htmlcode)), 177 | 'outline': '', 178 | 'runtime': getRuntime(htmlcode), 179 | 'director': getDirector(htmlcode), 180 | 'actor': getActor(htmlcode), 181 | 'release': getRelease(htmlcode), 182 | 'number': getNum(htmlcode), 183 | 'cover': getCover(htmlcode), 184 | 'tag': getTag(htmlcode), 185 | 'label': getSerise(htmlcode), 186 | 'imagecut': 3, 187 | 'cover_small': getCover_small(number), 188 | 'actor_photo': getActorPhoto(htmlcode), 189 | 'website': 'https://www.javbus.com/' + number, 190 | 'source': 'javbus.py', 191 | } 192 | if dic['cover_small'] == '': 193 | dic['imagecut'] = 0 194 | except: 195 | if htmlcode == 'ProxyError': 196 | dic = { 197 | 'title': '', 198 | 'website': 'timeout', 199 | } 200 | else: 201 | dic = { 202 | 'title': '', 203 | 'website': '', 204 | } 205 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') 206 | return js 207 | 208 | # print(main('SSNI-658')) 209 | # print(main_uncensored('122919-949')) 210 | # print(main_uncensored('012715-793')) 211 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AVDC 2 | 3 | 4 | # 目录 5 | * [简介](#简介) 6 | * [反馈](#反馈) 7 | * [声明](#声明) 8 | * [FAQ](#FAQ) 9 | * [故事](#故事) 10 | * [GUI运行截图](#GUI运行截图) 11 | * [效果图](#效果图) 12 | * [如何使用](#如何使用) 13 | * [下载](#下载) 14 | * [简明教程](#简要教程) 15 | * [模块安装](#1模块安装) 16 | * [配置设置](#2配置设置) 17 | * [小工具](#210工具) 18 | * [多目录影片处理](#3多目录影片处理) 19 | * [多集影片处理](#4多集影片处理) 20 | * [异常处理(重要)](#5异常处理重要) 21 | * [导入至媒体库](#7导入媒体库) 22 | * [关于群晖NAS](#8关于群晖NAS) 23 | * [写在后面](#9写在后面) 24 | 25 | 26 | # 简介 27 | **[命令行版](https://github.com/yoshiko2/AV_Data_Capture)(原作者)**:
28 | 29 | ![](https://img.shields.io/badge/build-passing-brightgreen.svg?style=flat-square) 30 | ![](https://img.shields.io/github/downloads/yoshiko2/av_data_capture/total.svg?style=flat-square) 31 | ![](https://img.shields.io/github/license/yoshiko2/av_data_capture.svg?style=flat-square) 32 | ![](https://img.shields.io/github/release/yoshiko2/av_data_capture.svg?style=flat-square) 33 | ![](https://img.shields.io/badge/Python-3.7-yellow.svg?style=flat-square&logo=python)
34 | **GUI版(本项目)**:
35 | 36 | ![](https://img.shields.io/badge/build-passing-brightgreen.svg?style=flat-square) 37 | ![](https://img.shields.io/github/downloads/moyy996/avdc/total.svg?style=flat-square) 38 | ![](https://img.shields.io/github/license/moyy996/avdc.svg?style=flat-square) 39 | ![](https://img.shields.io/github/release/moyy996/avdc.svg?style=flat-square) 40 | ![](https://img.shields.io/badge/Python-3.6-yellow.svg?style=flat-square&logo=python) 41 | ![](https://img.shields.io/badge/Pyqt-5-blue.svg?style=flat-square)
42 | 43 | ### 主要功能 44 | * **日本电影元数据 抓取工具 | 刮削器**,配合本地影片管理软件EMBY,KODI,PLEX等管理本地影片,该软件起到分类与元数据抓取作用,利用元数据信息来分类,供本地影片分类整理使用。
45 | * 可**批量抓取**,也可**单个抓取**。可抓取**子目录下视频**,**多集视频**(-cd1/-cd2),带**字幕**作品(-c., -C.)。
46 | * 目前可抓取网站:**javbus,javdb,avsox,fc2club,fanza**。
47 | * 批量添加Emby演员头像。
48 | 49 | ### 反馈 50 | * 欢迎使用体验,有**程序BUG问题、功能建议**,可进**电报群**反馈 [点击进群](https://t.me/joinchat/J54y1g3-a7nxJ_-WS4-KFQ)
51 | 52 | # 声明 53 | * 本软件仅供**技术交流,学术交流**使用
54 | * 本软件作者编写出该软件旨在学习Python3,提高编程水平
55 | * 用户在使用该软件前,请用户自觉遵守当地法律法规,如果该软件使用过程中存在违反当地法律法规的行为,请勿使用该软件
56 | * 用户使用该软件时,若产生一切违法行为由用户承担
57 | * 严禁用户使用于商业和个人其他意图
58 | * 本软件作者保留最终决定权和最终解释权
59 | 60 | **若用户不同意上述条款任意一条,请勿使用该软件**
61 | 62 | # FAQ 63 | ### 这软件能下片吗? 64 | * 该软件不提供任何影片下载地址,仅供本地影片分类整理使用。 65 | ### 什么是元数据? 66 | * 元数据包括了影片的:封面,导演,演员,简介,类型...... 67 | ### 软件收费吗? 68 | * 软件永久免费。**除了作者钦点以外** 69 | ### 软件运行异常怎么办? 70 | * 认真看 [异常处理(重要)](#5异常处理重要) 71 | 72 | # 故事 73 | [点击跳转至原作者博客文章](https://yoshiko2.github.io/2019/10/18/AVDC/) 74 | 75 | # GUI运行截图 76 | 77 | ## **主界面,设置,工具,关于** 78 | 79 |
80 | 81 | 82 |
83 |
84 | 85 | 86 |
87 | 88 | ## **查看成功番号的信息(GIF演示)** 89 |
90 | 91 |
92 | 93 | # 效果图 94 | ### **1、输出目录文件结构**
95 | 96 |
97 | 98 |
99 | 100 | ### **2、媒体库:以下为刮削、导入后的EMBY**
101 | 102 |
103 | 104 | 105 |
106 | 107 | # 如何使用 108 | ### 下载 109 | * **Release** 的程序可脱离**python环境**运行,源码包需要 [安装模块](#1模块安装)
110 | * **Release** 下载地址(**仅限Windows**): [点击下载](https://github.com/moyy996/AVDC/releases)
111 | * **源码包** 下载地址(**Windows,Linux,MacOS**): [点击下载](https://github.com/moyy996/AVDC/archive/master.zip)
112 | 113 | * Windows Python环境: [点击前往](https://www.python.org/downloads/windows/) 选中executable installer下载 114 | * MacOS Python环境: [点击前往](https://www.python.org/downloads/mac-osx/) 115 | * Linux Python环境:Linux用户懂的吧,不解释下载地址 116 | 117 | ### 简要教程:
118 | * **1.把软件拉到和电影的同一目录或者上级目录**
119 | * **2.运行AVDC.exe,配置设置页各项(配置方法请看以下教程)**
120 | * **3.点击开始等待完成(出错请开调试模式后截图)**
121 | * **4.把JAV_output导入至KODI,EMBY,PLEX中。**
122 | * **详细请看以下教程**
123 | 124 | ## 1.模块安装 125 | 如果运行**源码**版,运行前请安装**Python环境**和安装以下**模块**
126 | 在终端/cmd/Powershell中输入以下代码来安装模块
127 | **1、批量**从py-require.txt安装
128 | >pip install -r py-require.txt
129 | 130 | **2、单个**按需安装
131 | >pip install requests
132 | >pip install pyquery
133 | >pip install lxml
134 | >pip install Beautifulsoup4
135 | >pip install pillow
136 | >pip install pyqt5
137 | >pip install pyqt5-tools
138 | 139 | ## 2.配置设置 140 | **设置界面** 141 | ![](https://github.com/moyy996/AVDC/blob/master/readme/setting.png) 142 | 143 | --- 144 | ### 2.1.普通模式/整理模式 145 | **1、普通模式**:通过番号刮削数据,包括元数据、封面图、缩略图、背景图。
146 | **2、整理模式**:仅根据女优把电影命名为番号并分类到女优名称的文件夹下。
147 | 148 | --- 149 | ### 2.2.软链接模式:使用此模式,要以```管理员身份```运行。 150 | 刮削完**不移动视频**,而是在相应目录创建**软链接**(类似于快捷方式),方便PT下载完既想刮削又想继续上传的仓鼠党同志。 151 | 152 | --- 153 | ### 2.3.调试模式 154 | 输出番号的**元数据**,包括封面,导演,演员,简介等。 155 | 156 | --- 157 | ### 2.4.排除目录 158 | 在多层目录刮削时**排除所填目录**。 159 | 160 | --- 161 | ### 2.5.异常字符 162 | 在创建文件夹时,**删除指定的字符**。 163 | 164 | --- 165 | ### 2.6.命名规则 166 | **1、目录命名**:存放视频数据的目录名,支持**多层目录**,支持**自定义符号**,例:[actor]/studio/number-【title】。
167 | **2、视频标题**:nfo中的标题命名。例:number-[title]。可以自定义符号。
168 | **3、可选项**为title(片名)、actor(演员)、studio(公司)、director(导演)、release(发售日)、year(发行年份)、number(番号)、runtime(时长)、label(系列)
169 | 170 | --- 171 | ### 2.7.网络设置 172 | >proxy=127.0.0.1:1081
173 | 174 | * **proxy**行设置本地代理地址和端口,支持Shadowxxxx/X,V2XXX本地代理端口,代理软件开**全局模式** ,**建议使用日本代理**。
175 | * 如果一直报Connect Failed! Please check your Proxy or Network!错误,请检查**端口号**是否正确,或者把**proxy=后面的地址和端口**删除,并开启代理软件**全局模式**,或者重启电脑,代理软件,网卡。
176 | 177 | **连接超时重试设置**
178 | >timeout=10
179 | 180 | 10为超时重试时间 单位:秒
181 | **连接重试次数设置**
182 | >retry=3
183 | 184 | 3即为重试次数
185 | 186 | --- 187 | ### 2.8.媒体库选择 188 | 如果是PLEX,请安装插件:```XBMCnfoMoviesImporter``` 189 | 190 | --- 191 | ### 2.9.排除指定字符和目录 192 | **1、排除字符**:指定字符删除,例如```排除字符: \()```,删除标题中```\()```字符
193 | **2、排除目录**:指定目录,例如```排除目录: failed,JAV_output```,多目录刮削时跳过failed,JAV_output
194 | 195 | --- 196 | ### 2.11.网站选择 197 | **1、All website**: 使用avsox,javbus,fanza,javdb,fc2club,siro(mgstage)进行刮削。
198 | **2、Only javdb**: 仅使用javdb进行刮削。
199 | 200 | --- 201 | ### 2.10.工具 202 | **工具界面** 203 | ![](https://github.com/moyy996/AVDC/blob/master/readme/tool.png) 204 | **1、视频移动**:可将程序目录下除排除目录下的所有视频,移动到程序目录下。

205 | **2、单文件刮削**:偶尔有失败情况时,选择这个视频文件,使用文件名当番号进行刮削。
206 | **建议**的使用流程:到某网站找到这个番号,把番号改成网站上的规范番号,选用对应的网站刮削。
207 | **条件**:文件名至少与一个网站上的番号相同,没有多余的内容只有番号为最佳,可以让软件更好获取元数据。
208 | 对于多影片重命名,可以用[ReNamer](http://www.den4b.com/products/renamer)来批量重命名

209 | **3、Emby批量添加头像**:头像文件放在Actor目录下,填写emby网址、api密钥即可使用。[头像包下载](https://github.com/moyy996/AVDC/releases/tag/%E5%A4%B4%E5%83%8F%E5%8C%85-2)
210 | 可查看有头像,无头像女优,可往emby添加头像的女优。

211 | **4、裁剪封面**:针对封面图比例错误,分辨率低的情况,判断人脸位置,裁剪缩略图为封面图。

212 | 213 | 214 | ## 3.多目录影片处理 215 | 可以遍历**程序所在目录及子目录**(除指定的**排除目录**),对遍历到的所有视频进行刮削,成功则同**元数据、封面图**一起输出到**JAV_output**目录,失败移入**failed**目录。 216 | 217 | ## 4.多集影片处理 218 | 可以把多集电影按照集数后缀命名为类似**ssni-xxx-cd1.mp4,ssni-xxx-cd2.mp4,abp-xxx-CD1.mp4**的规则,只要含有```-CDn./-cdn.```类似命名规则,即可使用分集功能 219 | 220 | ## 5.异常处理(重要) 221 | ### 请确保软件是完整地!确保ini文件内容是和下载提供ini文件内容的一致的! 222 | 223 | --- 224 | ### 5.1.关于软件打开就闪退 225 | 可以打开cmd命令提示符,把 ```AVDC_Main.py/AVDC.exe```拖进cmd窗口回车运行,查看错误,出现的错误信息**依据以下条目解决** 226 | 227 | --- 228 | ### 5.2.报```Connect Failed! Please check your Proxy or Network!```错误 229 | 可以把文件的**proxy=后面的地址和端口删除**,并开启代理软件全局模式,或者重启电脑,代理软件,网卡 230 | 231 | --- 232 | ### 5.3.关于 ```Updata_check``` 和 ```JSON``` 相关的错误 233 | 跳转 [网络设置](#27网络设置) 234 | 235 | --- 236 | ### 5.4.关于字幕文件移动功能 237 | 字幕文件前缀必须与影片文件前缀一致,才可以使用该功能 238 | 239 | --- 240 | ### 5.5.关于```FileNotFoundError: [WinError 3] 系统找不到指定的路径。: 'JAV_output''``` 241 | 在软件所在文件夹下新建 JAV_output 文件夹,可能是你没有把软件拉到和电影的同一目录 242 | 243 | --- 244 | ### 5.6.关于连接拒绝的错误 245 | 请设置好[代理](#27网络设置)
246 | 247 | --- 248 | ### 5.7、关于Nonetype,xpath报错 249 | 同上
250 | 251 | --- 252 | ### 5.8.关于番号提取失败或者异常 253 | 目前可以提取元素的影片:**JAVBUS、JAVDB、AVSOX、FANZA、FC2CLUB**上有元数据的电影,请确保视频名能在这些网站找到
254 | 使用**工具页里的单个视频刮削**,选择**刮削网站**,进行刮削。
255 | 256 | --- 257 | ### 5.9.关于PIL/image.py 258 | 暂时无解,可能是网络问题或者pillow模块打包问题,你可以用源码运行(要安装好第一步的模块) 259 | 260 | 261 | ## 6.软件会自动把元数据获取成功的电影移动到JAV_output文件夹中,根据演员分类,失败的电影移动到failed文件夹中。 262 | ## 7.导入媒体库 263 | 把JAV_output文件夹导入到EMBY,KODI,PLEX中,等待元数据刷新,完成 264 | ## 8.关于群晖NAS 265 | 开启SMB在Windows上挂载为网络磁盘即可使用本软件,也适用于其他NAS 266 | ## 9.写在后面 267 | 怎么样,看着自己的日本电影被这样完美地管理,是不是感觉成就感爆棚呢?
268 | 269 | 270 | 271 | -------------------------------------------------------------------------------- /javdb.py: -------------------------------------------------------------------------------- 1 | import re 2 | from lxml import etree 3 | import json 4 | from ADC_function import * 5 | 6 | 7 | # import sys 8 | # import io 9 | # sys.stdout = io.TextIOWrapper(sys.stdout.buffer, errors = 'replace', line_buffering = True) 10 | def getTitle(a): 11 | try: 12 | html = etree.fromstring(a, etree.HTMLParser()) 13 | result = str(html.xpath('/html/body/section/div/h2/strong/text()')).strip(" ['']") 14 | return re.sub('.*\] ', '', result.replace('/', ',').replace('\\xa0', '').replace(' : ', '')) 15 | except: 16 | return re.sub('.*\] ', '', result.replace('/', ',').replace('\\xa0', '')) 17 | 18 | 19 | def getActor(a): # //*[@id="center_column"]/div[2]/div[1]/div/table/tbody/tr[1]/td/text() 20 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 21 | result1 = html.xpath('//strong[contains(text(),"演員")]/../following-sibling::span/text()') 22 | result2 = html.xpath('//strong[contains(text(),"演員")]/../following-sibling::span/a/text()') 23 | return result1 + result2 24 | 25 | 26 | def getActorPhoto(actor): # //*[@id="star_qdt"]/li/a/img 27 | d = {} 28 | for i in actor: 29 | if ',' not in i or ')' in i: 30 | p = {i: ''} 31 | d.update(p) 32 | return d 33 | 34 | 35 | def getStudio(a): 36 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 37 | result1 = str(html.xpath('//strong[contains(text(),"片商")]/../following-sibling::span/text()')).strip(" ['']") 38 | result2 = str(html.xpath('//strong[contains(text(),"片商")]/../following-sibling::span/a/text()')).strip(" ['']") 39 | return str(result1 + result2).strip('+').replace("', '", '').replace('"', '') 40 | 41 | 42 | def getRuntime(a): 43 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 44 | result1 = str(html.xpath('//strong[contains(text(),"時長")]/../following-sibling::span/text()')).strip(" ['']") 45 | result2 = str(html.xpath('//strong[contains(text(),"時長")]/../following-sibling::span/a/text()')).strip(" ['']") 46 | return str(result1 + result2).strip('+').rstrip('mi') 47 | 48 | 49 | def getLabel(a): 50 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 51 | result1 = str(html.xpath('//strong[contains(text(),"系列")]/../following-sibling::span/text()')).strip(" ['']") 52 | result2 = str(html.xpath('//strong[contains(text(),"系列")]/../following-sibling::span/a/text()')).strip(" ['']") 53 | return str(result1 + result2).strip('+').replace("', '", '').replace('"', '') 54 | 55 | 56 | def getNum(a): 57 | html = etree.fromstring(a, etree.HTMLParser()) 58 | result1 = str(html.xpath('//strong[contains(text(),"番號")]/../following-sibling::span/text()')).strip( 59 | " ['']").replace('_', '-') 60 | result2 = str(html.xpath('//strong[contains(text(),"番號")]/../following-sibling::span/a/text()')).strip( 61 | " ['']").replace('_', '-') 62 | return str(result2 + result1).strip('+') 63 | 64 | 65 | def getYear(getRelease): 66 | try: 67 | result = str(re.search('\d{4}', getRelease).group()) 68 | return result 69 | except: 70 | return getRelease 71 | 72 | 73 | def getRelease(a): 74 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 75 | result1 = str(html.xpath('//strong[contains(text(),"時間")]/../following-sibling::span/text()')).strip(" ['']") 76 | result2 = str(html.xpath('//strong[contains(text(),"時間")]/../following-sibling::span/a/text()')).strip(" ['']") 77 | return str(result1 + result2).strip('+') 78 | 79 | 80 | def getTag(a): 81 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 82 | result1 = str(html.xpath('//strong[contains(text(),"类别")]/../following-sibling::span/text()')).strip(" ['']") 83 | result2 = str(html.xpath('//strong[contains(text(),"类别")]/../following-sibling::span/a/text()')).strip(" ['']") 84 | return str(result1 + result2).strip('+').replace(",\\xa0", "").replace("'", "").replace(' ', '').replace(',,', 85 | '').lstrip( 86 | ',') 87 | 88 | 89 | def getCover_small(a, count): 90 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 91 | result = html.xpath("//div[@class='item-image fix-scale-cover']/img/@src")[count] 92 | if not 'https' in result: 93 | result = 'https:' + result 94 | return result 95 | 96 | 97 | def getCover(htmlcode): 98 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 99 | result = str(html.xpath("//div[@class='column column-video-cover']/a/img/@src")).strip(" ['']") 100 | return result 101 | 102 | 103 | def getDirector(a): 104 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 105 | result1 = str(html.xpath('//strong[contains(text(),"導演")]/../following-sibling::span/text()')).strip(" ['']") 106 | result2 = str(html.xpath('//strong[contains(text(),"導演")]/../following-sibling::span/a/text()')).strip(" ['']") 107 | return str(result1 + result2).strip('+').replace("', '", '').replace('"', '') 108 | 109 | 110 | def getOutline(htmlcode): 111 | html = etree.fromstring(htmlcode, etree.HTMLParser()) 112 | result = str(html.xpath('//*[@id="introduction"]/dd/p[1]/text()')).strip(" ['']") 113 | return result 114 | 115 | 116 | def main(number): 117 | try: 118 | a = get_html('https://javdb.com/search?q=' + number + '&f=all').replace(u'\xa0', u' ') 119 | html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() 120 | counts = len(html.xpath( 121 | '//div[@id=\'videos\']/div[@class=\'grid columns\']/div[@class=\'grid-item column\']')) 122 | if counts == 0: 123 | dic = { 124 | 'title': '', 125 | 'actor': '', 126 | 'website': '', 127 | } 128 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, 129 | separators=(',', ':'), ) # .encode('UTF-8') 130 | return js 131 | count = 1 132 | number_get = '' 133 | movie_found = 0 134 | for count in range(1, counts + 1): # 遍历搜索结果,找到需要的番号 135 | number_get = html.xpath( 136 | '//div[@id=\'videos\']/div[@class=\'grid columns\']/div[@class=\'grid-item column\'][' + str( 137 | count) + ']/a[@class=\'box\']/div[@class=\'uid\']/text()')[0] 138 | number_get = number_get.replace('_', '-') 139 | if number_get == number.upper() or number_get == number.lower(): 140 | movie_found = 1 141 | break 142 | result1 = html.xpath('//*[@id="videos"]/div/div/a/@href')[count - 1] 143 | b = get_html('https://javdb.com' + result1).replace(u'\xa0', u' ') 144 | actor = getActor(b) 145 | if len(actor) == 0 and 'FC2-' in number_get: 146 | actor.append('FC2-NoActor') 147 | if movie_found == 1: 148 | dic = { 149 | 'actor': str(actor).strip(" [',']").replace('\'', ''), 150 | 'title': getTitle(b).replace('中文字幕', '').replace("\\n", '').replace('_', '-').replace(number_get, 151 | '').strip().replace( 152 | ' ', '-').replace('--', '-'), 153 | 'studio': getStudio(b), 154 | 'outline': getOutline(b).replace('\n', ''), 155 | 'runtime': getRuntime(b), 156 | 'director': getDirector(b), 157 | 'release': getRelease(b), 158 | 'number': number_get, 159 | 'cover': getCover(b), 160 | 'cover_small': getCover_small(a, count - 1), 161 | 'imagecut': 3, 162 | 'tag': getTag(b), 163 | 'label': getLabel(b), 164 | 'year': getYear(getRelease(b)), # str(re.search('\d{4}',getRelease(a)).group()), 165 | 'actor_photo': getActorPhoto(actor), 166 | 'website': 'https://javdb.com' + result1, 167 | 'source': 'javdb.py', 168 | } 169 | else: # 未找到番号 170 | dic = { 171 | 'title': '', 172 | 'actor': str(actor).strip(" [',']").replace('\'', ''), 173 | 'website': '', 174 | } 175 | except: 176 | if a == 'ProxyError': 177 | dic = { 178 | 'title': '', 179 | 'actor': '', 180 | 'website': 'timeout', 181 | } 182 | else: 183 | dic = { 184 | 'title': '', 185 | 'actor': '', 186 | 'website': '', 187 | } 188 | js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') 189 | return js 190 | 191 | 192 | # print(main('LUXU-1217')) 193 | # input("[+][+]Press enter key exit, you can check the error messge before you exit.\n[+][+]按回车键结束,你可以在结束之前查看和错误信息。") 194 | # print(main('abs-141')) 195 | # print(main('040409-562')) 196 | # print(main('n1403')) 197 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /AVDC_Main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | import threading 4 | from PyQt5 import QtCore, QtGui, QtWidgets 5 | from PyQt5.QtWidgets import QApplication, QMainWindow 6 | from PyQt5.QtGui import QPixmap 7 | from PyQt5.QtGui import QTextCursor, QCursor 8 | from PyQt5.QtWidgets import * 9 | from PyQt5.QtCore import pyqtSignal, QThread, Qt 10 | from AVDC import * 11 | import sys 12 | import time 13 | import os.path 14 | import json 15 | from configparser import ConfigParser 16 | from AV_Data_Capture import * 17 | from core import * 18 | from fanza import * 19 | import requests 20 | import shutil 21 | import base64 22 | import re 23 | from aip import AipBodyAnalysis 24 | from PIL import Image 25 | import os 26 | 27 | 28 | class MyMAinWindow(QMainWindow, Ui_AVDV): 29 | progressBarValue = pyqtSignal(int) # 进度条信号量 30 | 31 | def __init__(self, parent=None): 32 | super(MyMAinWindow, self).__init__(parent) 33 | self.Ui = Ui_AVDV() # 实例化 Ui 34 | self.Ui.setupUi(self) # 初始化Ui 35 | self.Init_Ui() 36 | # 初始化需要的变量 37 | self.version = '3.61' 38 | self.m_drag = False 39 | self.m_DragPosition = 0 40 | self.item_succ = self.Ui.treeWidget_number.topLevelItem(0) 41 | self.item_fail = self.Ui.treeWidget_number.topLevelItem(1) 42 | self.json_array = {} 43 | self.Init() 44 | self.Load_Config() 45 | self.show_version() 46 | 47 | def Init_Ui(self): 48 | pix = QPixmap('AVDC-ico.png') 49 | self.Ui.label_ico.setScaledContents(True) 50 | self.Ui.label_ico.setPixmap(pix) # 添加图标 51 | self.Ui.progressBar_avdc.setValue(0) # 进度条清0 52 | self.progressBarValue.connect(self.set_processbar) 53 | self.Ui.progressBar_avdc.setTextVisible(False) # 不显示进度条文字 54 | self.setWindowFlag(QtCore.Qt.FramelessWindowHint) # 隐藏边框 55 | # self.setWindowOpacity(0.9) # 设置窗口透明度 56 | self.setAttribute(QtCore.Qt.WA_TranslucentBackground) # 设置窗口背景透明 57 | self.Ui.treeWidget_number.expandAll() 58 | self.Ui.checkBox_cover.setChecked(True) 59 | # 控件美化 60 | self.Ui.widget_setting.setStyleSheet( 61 | ''' 62 | QWidget#widget_setting{ 63 | background:#F0F8FF; 64 | border-radius:20px; 65 | padding:2px 4px; 66 | } 67 | QPushButton{ 68 | font-size:15px; 69 | background:gray; 70 | border:9px solid gray; 71 | border-radius:15px; 72 | padding:2px 4px; 73 | } 74 | 75 | ''') 76 | self.Ui.centralwidget.setStyleSheet( 77 | ''' 78 | QWidget#centralwidget{ 79 | background:gray; 80 | border:1px solid gray; 81 | width:300px; 82 | border-radius:20px; 83 | padding:2px 4px; 84 | } 85 | QTextBrowser{ 86 | border:1px solid gray; 87 | background:white; 88 | width:300px; 89 | border-radius:10px; 90 | padding:2px 4px; 91 | } 92 | QLineEdit{ 93 | background:white; 94 | border:1px solid white; 95 | width:300px; 96 | border-radius:10px; 97 | padding:2px 4px; 98 | } 99 | QTextBrowser#textBrowser_about{ 100 | background:white; 101 | border:1px solid white; 102 | width:300px; 103 | border-radius:10px; 104 | padding:2px 4px; 105 | } 106 | QTextBrowser#textBrowser_warning{ 107 | background:gray; 108 | border:1px solid gray; 109 | width:300px; 110 | border-radius:10px; 111 | padding:2px 4px; 112 | } 113 | QPushButton#pushButton_start_cap,#pushButton_move_mp4,#pushButton_select_file,#pushButton_select_fanart{ 114 | font-size:20px; 115 | background:#F0F8FF; 116 | border:2px solid white; 117 | width:300px; 118 | border-radius:20px; 119 | padding:2px 4px; 120 | } 121 | QPushButton#pushButton_add_actor_pic{ 122 | font-size:20px; 123 | background:#F0F8FF; 124 | border:2px solid white; 125 | width:300px; 126 | border-radius:20px; 127 | padding:2px 4px; 128 | } 129 | QPushButton#pushButton_save_config,#pushButton_show_pic_actor{ 130 | font-size:20px; 131 | background:#F0F8FF; 132 | border:2px solid white; 133 | width:300px; 134 | border-radius:13px; 135 | padding:2px 4px; 136 | } 137 | QProgressBar::chunk{ 138 | background-color: #2196F3; 139 | width: 5px; /*区块宽度*/ 140 | margin: 0.5px; 141 | } 142 | ''') 143 | 144 | # ========================================================================按钮点击事件 145 | def Init(self): 146 | self.Ui.stackedWidget.setCurrentIndex(0) 147 | self.Ui.treeWidget_number.clicked.connect(self.treeWidget_number_clicked) 148 | self.Ui.pushButton_close.clicked.connect(self.close_win) 149 | self.Ui.pushButton_min.clicked.connect(self.min_win) 150 | self.Ui.pushButton_main.clicked.connect(self.pushButton_main_clicked) 151 | self.Ui.pushButton_tool.clicked.connect(self.pushButton_tool_clicked) 152 | self.Ui.pushButton_setting.clicked.connect(self.pushButton_setting_clicked) 153 | self.Ui.pushButton_select_file.clicked.connect(self.pushButton_select_file_clicked) 154 | self.Ui.pushButton_about.clicked.connect(self.pushButton_about_clicked) 155 | self.Ui.pushButton_start_cap.clicked.connect(self.pushButton_start_cap_clicked) 156 | self.Ui.pushButton_save_config.clicked.connect(self.pushButton_save_config_clicked) 157 | self.Ui.pushButton_move_mp4.clicked.connect(self.move_file) 158 | self.Ui.pushButton_add_actor_pic.clicked.connect(self.pushButton_add_actor_pic_clicked) 159 | self.Ui.pushButton_show_pic_actor.clicked.connect(self.pushButton_show_pic_actor_clicked) 160 | self.Ui.pushButton_select_fanart.clicked.connect(self.pushButton_select_fanart_clicked) 161 | self.Ui.pushButton_log.clicked.connect(self.pushButton_show_log_clicked) 162 | self.Ui.checkBox_cover.stateChanged.connect(self.cover_change) 163 | 164 | # ========================================================================加载config 165 | def Load_Config(self): 166 | config_file = 'config.ini' 167 | config = ConfigParser() 168 | config.read(config_file, encoding='UTF-8') 169 | if int(config['common']['main_mode']) == 1: 170 | self.Ui.radioButton_common.setChecked(True) 171 | elif int(config['common']['main_mode']) == 2: 172 | self.Ui.radioButton_sort.setChecked(True) 173 | if int(config['common']['soft_link']) == 1: 174 | self.Ui.radioButton_soft_on.setChecked(True) 175 | elif int(config['common']['soft_link']) == 0: 176 | self.Ui.radioButton_soft_off.setChecked(True) 177 | if int(config['update']['update_check']) == 1: 178 | self.Ui.radioButton_update_on.setChecked(True) 179 | elif int(config['update']['update_check']) == 0: 180 | self.Ui.radioButton_update_off.setChecked(True) 181 | if int(config['debug_mode']['switch']) == 1: 182 | self.Ui.radioButton_debug_on.setChecked(True) 183 | elif int(config['debug_mode']['switch']) == 0: 184 | self.Ui.radioButton_debug_off.setChecked(True) 185 | if config['media']['media_warehouse'] == 'emby' or config['media']['media_warehouse'] == 'jellyfin': 186 | self.Ui.radioButton_emby.setChecked(True) 187 | elif config['media']['media_warehouse'] == 'plex': 188 | self.Ui.radioButton_plex.setChecked(True) 189 | elif config['media']['media_warehouse'] == 'kodi': 190 | self.Ui.radioButton_kodi.setChecked(True) 191 | if config['common']['website'] == 'all': 192 | self.Ui.radioButton_all.setChecked(True) 193 | elif config['common']['website'] == 'javdb': 194 | self.Ui.radioButton_javdb.setChecked(True) 195 | self.Ui.lineEdit_success.setText(config['common']['success_output_folder']) 196 | self.Ui.lineEdit_fail.setText(config['common']['failed_output_folder']) 197 | self.Ui.lineEdit_escape_dir.setText(config['escape']['folders']) 198 | self.Ui.lineEdit_escape_char.setText(config['escape']['literals']) 199 | self.Ui.lineEdit_proxy.setText(config['proxy']['proxy']) 200 | self.Ui.lineEdit_timeout.setText(config['proxy']['timeout']) 201 | self.Ui.lineEdit_retry.setText(config['proxy']['retry']) 202 | self.Ui.lineEdit_dir_name.setText(config['Name_Rule']['location_rule']) 203 | self.Ui.lineEdit_media_name.setText(config['Name_Rule']['naming_rule']) 204 | self.Ui.lineEdit_escape_dir_move.setText(config['escape']['folders']) 205 | self.Ui.lineEdit_emby_url.setText(config['emby']['emby_url']) 206 | self.Ui.lineEdit_api_key.setText(config['emby']['api_key']) 207 | 208 | # ========================================================================显示版本号 209 | def show_version(self): 210 | self.add_text_main('[*]======================== AVDC ========================') 211 | self.add_text_main('[*] Version ' + self.version) 212 | self.add_text_main('[*]======================================================') 213 | 214 | # ========================================================================鼠标拖动窗口 215 | def mousePressEvent(self, e): 216 | if e.button() == Qt.LeftButton: 217 | self.m_drag = True 218 | self.m_DragPosition = e.globalPos() - self.pos() 219 | self.setCursor(QCursor(Qt.OpenHandCursor)) 220 | 221 | def mouseReleaseEvent(self, e): 222 | if e.button() == Qt.LeftButton: 223 | self.m_drag = False 224 | self.setCursor(QCursor(Qt.ArrowCursor)) 225 | 226 | def mouseMoveEvent(self, e): 227 | if Qt.LeftButton and self.m_drag: 228 | self.move(e.globalPos() - self.m_DragPosition) 229 | e.accept() 230 | 231 | # ========================================================================左侧按钮点击事件响应函数 232 | def close_win(self): 233 | os._exit(0) 234 | 235 | def min_win(self): 236 | self.setWindowState(Qt.WindowMinimized) 237 | 238 | def pushButton_main_clicked(self): 239 | self.Ui.stackedWidget.setCurrentIndex(0) 240 | 241 | def pushButton_tool_clicked(self): 242 | self.Ui.stackedWidget.setCurrentIndex(1) 243 | 244 | def pushButton_setting_clicked(self): 245 | self.Ui.stackedWidget.setCurrentIndex(2) 246 | 247 | def pushButton_about_clicked(self): 248 | self.Ui.stackedWidget.setCurrentIndex(3) 249 | 250 | def pushButton_show_log_clicked(self): 251 | self.Ui.stackedWidget.setCurrentIndex(4) 252 | 253 | def cover_change(self): 254 | if not self.Ui.checkBox_cover.isChecked(): 255 | self.Ui.label_poster.setText("封面图") 256 | self.Ui.label_fanart.setText("缩略图") 257 | 258 | def treeWidget_number_clicked(self, qmodeLindex): 259 | item = self.Ui.treeWidget_number.currentItem() 260 | if item.text(0) != '成功' and item.text(0) != '失败': 261 | try: 262 | index_json = str(item.text(0)).split('.')[0] 263 | self.add_label_info(self.json_array[str(index_json)]) 264 | except: 265 | print('Error in treeWidget_number_clicked!') 266 | 267 | def pushButton_start_cap_clicked(self): 268 | self.Ui.pushButton_start_cap.setEnabled(False) 269 | try: 270 | t = threading.Thread(target=self.AVDC_Main) 271 | t.start() # 启动线程,即让线程开始执行 272 | except Exception as error_info: 273 | self.add_text_main('[-]Error in pushButton_start_cap_clicked: ' + str(error_info)) 274 | 275 | def pushButton_save_config_clicked(self): 276 | try: 277 | t = threading.Thread(target=self.save_config_clicked) 278 | t.start() # 启动线程,即让线程开始执行 279 | except Exception as error_info: 280 | self.add_text_main('[-]Error in pushButton_save_config_clicked: ' + str(error_info)) 281 | 282 | # ========================================================================读取设置页设置,保存在config.ini 283 | def save_config_clicked(self): 284 | main_mode = 1 285 | soft_link = 0 286 | switch_debug = 0 287 | update_check = 0 288 | media_warehouse = '' 289 | website = '' 290 | if self.Ui.radioButton_common.isChecked(): # 普通模式 291 | main_mode = 1 292 | elif self.Ui.radioButton_sort.isChecked(): # 整理模式 293 | main_mode = 2 294 | if self.Ui.radioButton_soft_on.isChecked(): # 软链接开 295 | soft_link = 1 296 | elif self.Ui.radioButton_soft_off.isChecked(): # 软链接关 297 | soft_link = 0 298 | if self.Ui.radioButton_debug_on.isChecked(): # 调试模式开 299 | switch_debug = 1 300 | elif self.Ui.radioButton_debug_off.isChecked(): # 调试模式关 301 | switch_debug = 0 302 | if self.Ui.radioButton_update_on.isChecked(): # 检查更新 303 | update_check = 1 304 | elif self.Ui.radioButton_update_off.isChecked(): # 不检查更新 305 | update_check = 0 306 | if self.Ui.radioButton_emby.isChecked(): # emby/jellyfin 307 | media_warehouse = 'emby' 308 | elif self.Ui.radioButton_plex.isChecked(): # plex 309 | media_warehouse = 'plex' 310 | elif self.Ui.radioButton_kodi.isChecked(): # kodi 311 | media_warehouse = 'kodi' 312 | if self.Ui.radioButton_all.isChecked(): # all 313 | website = 'all' 314 | elif self.Ui.radioButton_javdb.isChecked(): # javdb 315 | website = 'javdb' 316 | json_config = { 317 | 'main_mode': main_mode, 318 | 'soft_link': soft_link, 319 | 'switch_debug': switch_debug, 320 | 'update_check': update_check, 321 | 'media_warehouse': media_warehouse, 322 | 'website': website, 323 | 'failed_output_folder': self.Ui.lineEdit_fail.text(), 324 | 'success_output_folder': self.Ui.lineEdit_success.text(), 325 | 'proxy': self.Ui.lineEdit_proxy.text(), 326 | 'timeout': self.Ui.lineEdit_timeout.text(), 327 | 'retry': self.Ui.lineEdit_retry.text(), 328 | 'location_rule': self.Ui.lineEdit_dir_name.text(), 329 | 'naming_rule': self.Ui.lineEdit_media_name.text(), 330 | 'literals': self.Ui.lineEdit_escape_char.text(), 331 | 'folders': self.Ui.lineEdit_escape_dir.text(), 332 | 'emby_url': self.Ui.lineEdit_emby_url.text(), 333 | 'api_key': self.Ui.lineEdit_api_key.text(), 334 | } 335 | save_config(json_config) 336 | 337 | # ========================================================================小工具-单视频刮削 338 | def pushButton_select_file_clicked(self): 339 | filePath, fileType = QtWidgets.QFileDialog.getOpenFileName(self, "选取文件", os.getcwd(), 340 | "Movie Files(*.mp4 *.avi *.rmvb " 341 | "*.wmv *.mov *.mkv *.flv *.ts *.MP4 *.AVI *.RMVB " 342 | "*.WMV *.MOV *.MKV *.FLV *.TS);;All Files(*)") 343 | if filePath != '': 344 | self.Ui.stackedWidget.setCurrentIndex(0) 345 | try: 346 | t = threading.Thread(target=self.select_file_thread, args=(filePath,)) 347 | t.start() # 启动线程,即让线程开始执行 348 | except Exception as error_info: 349 | self.add_text_main('[-]Error in pushButton_select_file_clicked: ' + str(error_info)) 350 | 351 | def select_file_thread(self, file_name): 352 | file_root = os.getcwd().replace("\\\\", "/").replace("\\", "/") 353 | file_path = file_name.replace(file_root, '.').replace("\\\\", "/").replace("\\", "/") 354 | file_name = os.path.splitext(file_name.split('/')[-1])[0] 355 | mode = 0 356 | if self.Ui.comboBox_website.currentText() == 'All websites': 357 | mode = 1 358 | elif self.Ui.comboBox_website.currentText() == 'javdb': 359 | mode = 2 360 | elif self.Ui.comboBox_website.currentText() == 'javbus': 361 | mode = 3 362 | elif self.Ui.comboBox_website.currentText() == 'avsox': 363 | mode = 4 364 | elif self.Ui.comboBox_website.currentText() == 'fc2club': 365 | mode = 5 366 | elif self.Ui.comboBox_website.currentText() == 'fanza': 367 | mode = 6 368 | elif self.Ui.comboBox_website.currentText() == 'siro': 369 | mode = 7 370 | try: 371 | if '-CD' in file_name or '-cd' in file_name: 372 | part = '' 373 | if re.search('-CD\d+', file_name): 374 | part = re.findall('-CD\d+', file_name)[0] 375 | elif re.search('-cd\d+', file_name): 376 | part = re.findall('-cd\d+', file_name)[0] 377 | file_name = file_name.replace(part, '') 378 | if '-c.' in file_path or '-C.' in file_path: 379 | file_name = file_name[0:-2] 380 | self.add_text_main("[!]Making Data for [" + file_path + "], the number is [" + file_name + "]") 381 | self.Core_Main(file_path, file_name, mode, 0) 382 | except Exception as error_info: 383 | self.add_text_main('[-]Error in select_file_thread: ' + str(error_info)) 384 | self.add_text_main("[*]======================================================") 385 | 386 | # ========================================================================小工具-裁剪封面图 387 | def pushButton_select_fanart_clicked(self): 388 | filePath, fileType = QtWidgets.QFileDialog.getOpenFileName(self, "选取文件", os.getcwd(), 389 | "Picture Files(*.jpg);;All Files(*)") 390 | if filePath != '': 391 | self.Ui.stackedWidget.setCurrentIndex(0) 392 | try: 393 | t = threading.Thread(target=self.select_fanart_thread, args=(filePath,)) 394 | t.start() # 启动线程,即让线程开始执行 395 | except Exception as error_info: 396 | self.add_text_main('[-]Error in pushButton_select_fanart_clicked: ' + str(error_info)) 397 | 398 | def select_fanart_thread(self, file_path): 399 | file_name = file_path.split('/')[-1] 400 | file_path = file_path.replace('/' + file_name, '') 401 | self.image_cut(file_path, file_name) 402 | self.add_text_main("[*]======================================================") 403 | 404 | def image_cut(self, path, file_name): 405 | file_path = os.path.join(path, file_name) 406 | png_name = '' 407 | if self.Ui.radioButton_emby.isChecked(): # emby/jellyfin 408 | png_name = os.path.splitext(file_name)[0] + '.png' 409 | elif self.Ui.radioButton_plex.isChecked(): # plex 410 | png_name = 'poster.png' 411 | elif self.Ui.radioButton_kodi.isChecked(): # kodi 412 | png_name = file_name.replace('-fanart.jpg', '-poster.png') 413 | try: 414 | if os.path.exists(os.path.join(path, png_name)): 415 | os.remove(os.path.join(path, png_name)) 416 | except Exception as error_info: 417 | self.add_text_main('[-]Error in image_cut: ' + str(error_info)) 418 | return 419 | 420 | """ 你的 APPID AK SK """ 421 | APP_ID = '17013175' 422 | API_KEY = 'IQs1mkG4FerdtmNh6qKDI4fW' 423 | SECRET_KEY = 'dLr9GTqqutqP9nWKKRaEinVDhxYlPbnD' 424 | 425 | client = AipBodyAnalysis(APP_ID, API_KEY, SECRET_KEY) 426 | 427 | """ 获取图片分辨率 """ 428 | im = Image.open(file_path) # 返回一个Image对象 429 | width, height = im.size 430 | 431 | """ 读取图片 """ 432 | with open(file_path, 'rb') as fp: 433 | image = fp.read() 434 | 435 | """ 调用人体检测与属性识别 """ 436 | result = client.bodyAnalysis(image) 437 | ewidth = int(0.661538 * height) 438 | ex = int(result["person_info"][0]['body_parts']['nose']['x']) 439 | if width - ex < ewidth / 2: 440 | ex = width - ewidth 441 | else: 442 | ex -= int(ewidth / 2) 443 | ey = 0 444 | ew = ewidth 445 | eh = height 446 | fp = open(file_path, 'rb') 447 | img = Image.open(fp) 448 | img_new_png = img.crop((ex, ey, ew + ex, eh + ey)) 449 | fp.close() 450 | img_new_png.save(path + '/' + png_name) 451 | self.add_text_main('[+]Poster Cut ' + png_name + ' from ' + file_name + '!') 452 | pix = QPixmap(file_path) 453 | self.Ui.label_fanart.setScaledContents(True) 454 | self.Ui.label_fanart.setPixmap(pix) # 添加图标 455 | pix = QPixmap(path + '/' + png_name) 456 | self.Ui.label_poster.setScaledContents(True) 457 | self.Ui.label_poster.setPixmap(pix) # 添加图标 458 | 459 | # ========================================================================小工具-视频移动 460 | def move_file(self): 461 | self.Ui.stackedWidget.setCurrentIndex(4) 462 | try: 463 | t = threading.Thread(target=self.move_file_thread) 464 | t.start() # 启动线程,即让线程开始执行 465 | except Exception as error_info: 466 | self.add_text_main('[-]Error in move_file: ' + str(error_info)) 467 | 468 | def move_file_thread(self): 469 | escape_dir = self.Ui.lineEdit_escape_dir_move.text() 470 | movie_list = movie_lists(escape_dir) 471 | self.add_text_main('[+]Move Movies Start!') 472 | for movie in movie_list: 473 | sour = movie 474 | lenth = len(sour.split('/')) 475 | des = os.getcwd() + '/' + sour.split('/')[lenth - 1] 476 | try: 477 | if len(sour.split('/')) > 2: 478 | shutil.move(sour, des) 479 | self.add_text_main(' [+]Move ' + sour.split('/')[lenth - 1] + ' Success!') 480 | except Exception as error_info: 481 | self.add_text_main('[-]Error in move_file_thread: ' + str(error_info)) 482 | self.add_text_main("[+]Move Movies All Finished!!!") 483 | self.add_text_main("[*]======================================================") 484 | 485 | # ========================================================================小工具-emby女优头像 486 | def pushButton_add_actor_pic_clicked(self): # 添加头像按钮响应 487 | self.Ui.stackedWidget.setCurrentIndex(0) 488 | emby_url = self.Ui.lineEdit_emby_url.text() 489 | api_key = self.Ui.lineEdit_api_key.text() 490 | if emby_url == '': 491 | self.add_text_main('[-]The emby_url is empty!') 492 | self.add_text_main("[*]======================================================") 493 | return 494 | elif api_key == '': 495 | self.add_text_main('[-]The api_key is empty!') 496 | self.add_text_main("[*]======================================================") 497 | return 498 | try: 499 | t = threading.Thread(target=self.found_profile_picture, args=(1,)) 500 | t.start() # 启动线程,即让线程开始执行 501 | except Exception as error_info: 502 | self.add_text_main('[-]Error in pushButton_add_actor_pic_clicked: ' + str(error_info)) 503 | 504 | def pushButton_show_pic_actor_clicked(self): # 查看按钮响应 505 | self.Ui.stackedWidget.setCurrentIndex(0) 506 | emby_url = self.Ui.lineEdit_emby_url.text() 507 | api_key = self.Ui.lineEdit_api_key.text() 508 | if emby_url == '': 509 | self.add_text_main('[-]The emby_url is empty!') 510 | self.add_text_main("[*]======================================================") 511 | return 512 | elif api_key == '': 513 | self.add_text_main('[-]The api_key is empty!') 514 | self.add_text_main("[*]======================================================") 515 | return 516 | if self.Ui.comboBox_pic_actor.currentIndex() == 0: # 可添加头像的女优 517 | try: 518 | t = threading.Thread(target=self.found_profile_picture, args=(2,)) 519 | t.start() # 启动线程,即让线程开始执行 520 | except Exception as error_info: 521 | self.add_text_main('[-]Error in pushButton_show_pic_actor_clicked: ' + str(error_info)) 522 | else: 523 | try: 524 | t = threading.Thread(target=self.show_actor, args=(self.Ui.comboBox_pic_actor.currentIndex(),)) 525 | t.start() # 启动线程,即让线程开始执行 526 | except Exception as error_info: 527 | self.add_text_main('[-]Error in pushButton_show_pic_actor_clicked: ' + str(error_info)) 528 | 529 | def show_actor(self, mode): # 按模式显示相应列表 530 | if mode == 1: # 没有头像的女优 531 | self.add_text_main('[+]没有头像的女优!') 532 | elif mode == 2: # 有头像的女优 533 | self.add_text_main('[+]有头像的女优!') 534 | elif mode == 3: # 所有女优 535 | self.add_text_main('[+]所有女优!') 536 | actor_list = self.get_emby_actor_list() 537 | if actor_list['TotalRecordCount'] == 0: 538 | self.add_text_main("[*]======================================================") 539 | return 540 | count = 1 541 | actor_list_temp = '' 542 | for actor in actor_list['Items']: 543 | if mode == 3: # 所有女优 544 | actor_list_temp += str(count) + '.' + actor['Name'] + ',' 545 | count += 1 546 | elif mode == 2 and actor['ImageTags'] != {}: # 有头像的女优 547 | actor_list_temp += str(count) + '.' + actor['Name'] + ',' 548 | count += 1 549 | elif mode == 1 and actor['ImageTags'] == {}: # 没有头像的女优 550 | actor_list_temp += str(count) + '.' + actor['Name'] + ',' 551 | count += 1 552 | if (count - 1) % 5 == 0 and actor_list_temp != '': 553 | self.add_text_main('[+]' + actor_list_temp) 554 | actor_list_temp = '' 555 | self.add_text_main("[*]======================================================") 556 | 557 | def get_emby_actor_list(self): # 获取emby的演员列表 558 | emby_url = self.Ui.lineEdit_emby_url.text() 559 | api_key = self.Ui.lineEdit_api_key.text() 560 | emby_url = emby_url.replace(':', ':') 561 | url = 'http://' + emby_url + '/emby/Persons?api_key=' + api_key 562 | headers = { 563 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' 564 | 'Chrome/60.0.3100.0 Safari/537.36'} 565 | getweb = requests.get(str(url), headers=headers, timeout=10) 566 | getweb.encoding = 'utf-8' 567 | actor_list = {} 568 | try: 569 | actor_list = json.loads(getweb.text) 570 | except: 571 | self.add_text_main('[-]Error! Check your emby_url or api_key!') 572 | actor_list['TotalRecordCount'] = 0 573 | return actor_list 574 | 575 | def found_profile_picture(self, mode): # mode=1,上传头像,mode=2,显示可添加头像的女优 576 | if mode == 1: 577 | self.add_text_main('[+]Start upload profile pictures!') 578 | elif mode == 2: 579 | self.add_text_main('[+]可添加头像的女优!') 580 | path = 'Actor' 581 | if not os.path.exists(path): 582 | self.add_text_main('[+]Actor folder not exist!') 583 | self.add_text_main("[*]======================================================") 584 | return 585 | path_success = 'Actor/Success' 586 | if not os.path.exists(path_success): 587 | os.makedirs(path_success) 588 | profile_pictures = os.listdir(path) 589 | actor_list = self.get_emby_actor_list() 590 | if actor_list['TotalRecordCount'] == 0: 591 | self.add_text_main("[*]======================================================") 592 | return 593 | count = 1 594 | for actor in actor_list['Items']: 595 | flag = 0 596 | pic_name = '' 597 | if actor['Name'] + '.jpg' in profile_pictures: 598 | flag = 1 599 | pic_name = actor['Name'] + '.jpg' 600 | elif actor['Name'] + '.png' in profile_pictures: 601 | flag = 1 602 | pic_name = actor['Name'] + '.png' 603 | if flag == 0: 604 | byname_list = re.split('[,()]', actor['Name']) 605 | for byname in byname_list: 606 | if byname + '.jpg' in profile_pictures: 607 | pic_name = byname + '.jpg' 608 | flag = 1 609 | break 610 | elif byname + '.png' in profile_pictures: 611 | pic_name = byname + '.png' 612 | flag = 1 613 | break 614 | if flag == 1 and (actor['ImageTags'] == {} or not os.path.exists(path_success + '/' + pic_name)): 615 | if mode == 1: 616 | try: 617 | self.upload_profile_picture(count, actor, path + '/' + pic_name) 618 | shutil.copy(path + '/' + pic_name, path_success + '/' + pic_name) 619 | except Exception as error_info: 620 | self.add_text_main('[-]Error in found_profile_picture! ' + str(error_info)) 621 | else: 622 | self.add_text_main('[+]' + "%4s" % str(count) + '.Actor name: ' + actor['Name'] + ' Pic name: ' 623 | + pic_name) 624 | count += 1 625 | if count == 1: 626 | self.add_text_main('[-]NO profile picture can be uploaded!') 627 | self.add_text_main("[*]======================================================") 628 | 629 | def upload_profile_picture(self, count, actor, pic_path): # 上传头像 630 | emby_url = self.Ui.lineEdit_emby_url.text() 631 | api_key = self.Ui.lineEdit_api_key.text() 632 | emby_url = emby_url.replace(':', ':') 633 | try: 634 | f = open(pic_path, 'rb') # 二进制方式打开图文件 635 | b6_pic = base64.b64encode(f.read()) # 读取文件内容,转换为base64编码 636 | f.close() 637 | url = 'http://' + emby_url + '/emby/Items/' + actor['Id'] + '/Images/Primary?api_key=' + api_key 638 | if pic_path.endswith('jpg'): 639 | header = {"Content-Type": 'image/png', } 640 | else: 641 | header = {"Content-Type": 'image/jpeg', } 642 | respones = requests.post(url=url, data=b6_pic, headers=header) 643 | self.add_text_main( 644 | '[+]' + "%4s" % str(count) + '.Success upload profile picture for ' + actor['Name'] + '!') 645 | except Exception as error_info: 646 | self.add_text_main('[-]Error in upload_profile_picture! ' + str(error_info)) 647 | 648 | # ========================================================================core.py 649 | def add_text_main(self, text): 650 | time.sleep(0.1) 651 | self.Ui.textBrowser_log_main.append(text) 652 | self.Ui.textBrowser_log_main.moveCursor(QTextCursor.End) 653 | 654 | def moveFailedFolder(self, filepath, failed_folder): 655 | self.add_text_main('[-]Move to Failed output folder') 656 | shutil.move(filepath, str(os.getcwd()) + '/' + failed_folder + '/') 657 | 658 | # =====================资源下载部分=========================== 659 | def DownloadFileWithFilename(self, url, filename, path, Config, filepath, 660 | failed_folder): # path = examle:photo , video.in the Project Folder! 661 | retry_count = 0 662 | proxy = '' 663 | timeout = 0 664 | try: 665 | proxy = Config['proxy']['proxy'] 666 | timeout = int(Config['proxy']['timeout']) 667 | retry_count = int(Config['proxy']['retry']) 668 | except: 669 | self.add_text_main('[-]Proxy config error! Please check the config.') 670 | i = 0 671 | 672 | while i < retry_count: 673 | try: 674 | if not proxy == '': 675 | if not os.path.exists(path): 676 | os.makedirs(path) 677 | headers = { 678 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'} 679 | r = requests.get(url, headers=headers, timeout=timeout, 680 | proxies={"http": "http://" + str(proxy), "https": "https://" + str(proxy)}) 681 | if r == '': 682 | self.add_text_main('[-]Movie Data not found!') 683 | # os._exit(0) 684 | with open(str(path) + "/" + filename, "wb") as code: 685 | code.write(r.content) 686 | return 687 | else: 688 | if not os.path.exists(path): 689 | os.makedirs(path) 690 | headers = { 691 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'} 692 | r = requests.get(url, timeout=timeout, headers=headers) 693 | if r == '': 694 | self.add_text_main('[-]Movie Data not found!') 695 | # os._exit(0) 696 | with open(str(path) + "/" + filename, "wb") as code: 697 | code.write(r.content) 698 | return 699 | except requests.exceptions.RequestException: 700 | i += 1 701 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count)) 702 | except requests.exceptions.ConnectionError: 703 | i += 1 704 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count)) 705 | except requests.exceptions.ProxyError: 706 | i += 1 707 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count)) 708 | except requests.exceptions.ConnectTimeout: 709 | i += 1 710 | print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count)) 711 | self.add_text_main('[-]Connect Failed! Please check your Proxy or Network!') 712 | self.moveFailedFolder(filepath, failed_folder) 713 | 714 | def fanartDownload(self, option, cover, number, c_word, path, multi_part, Config, filepath, 715 | failed_folder): # 封面是否下载成功,否则移动到failed 716 | if option == 'emby': 717 | if self.DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, 718 | failed_folder) == 'failed': 719 | self.moveFailedFolder(filepath, failed_folder) 720 | self.DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder) 721 | if not os.path.getsize(path + '/' + number + c_word + '.jpg') == 0: 722 | self.add_text_main('[+]Fanart Downloaded! ' + number + c_word + '.jpg') 723 | return 724 | i = 1 725 | while i <= int(Config['proxy']['retry']): 726 | if os.path.getsize(path + '/' + number + c_word + '.jpg') == 0: 727 | print('[!]Image Download Failed! Trying again. ' + str(i) + '/' + Config['proxy']['retry']) 728 | self.DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, 729 | failed_folder) 730 | i = i + 1 731 | else: 732 | break 733 | if multi_part == 1: 734 | old_name = os.path.join(path, number + c_word + '.jpg') 735 | new_name = os.path.join(path, number + c_word + '.jpg') 736 | os.rename(old_name, new_name) 737 | self.add_text_main('[+]Fanart Downloaded! ' + number + c_word + '.jpg') 738 | else: 739 | self.add_text_main('[+]Fanart Downloaded! ' + number + c_word + '.jpg') 740 | elif option == 'plex': 741 | if self.DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder) == 'failed': 742 | self.moveFailedFolder(filepath, failed_folder) 743 | self.DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder) 744 | if not os.path.getsize(path + '/fanart.jpg') == 0: 745 | self.add_text_main('[+]Fanart Downloaded! fanart.jpg') 746 | return 747 | i = 1 748 | while i <= int(Config['proxy']['retry']): 749 | if os.path.getsize(path + '/fanart.jpg') == 0: 750 | print('[!]Image Download Failed! Trying again. ' + str(i) + '/' + Config['proxy']['retry']) 751 | self.DownloadFileWithFilename(cover, 'fanart.jpg', path, Config, filepath, failed_folder) 752 | i = i + 1 753 | continue 754 | else: 755 | break 756 | if not os.path.getsize(path + '/' + number + c_word + '.jpg') == 0: 757 | print('[!]Image Download Failed! Trying again.') 758 | self.DownloadFileWithFilename(cover, number + c_word + '.jpg', path, Config, filepath, failed_folder) 759 | self.add_text_main('[+]Fanart Downloaded! fanart.jpg') 760 | elif option == 'kodi': 761 | if self.DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, 762 | failed_folder) == 'failed': 763 | self.moveFailedFolder(filepath, failed_folder) 764 | self.DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, failed_folder) 765 | if not os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0: 766 | self.add_text_main('[+]Fanart Downloaded! ' + number + c_word + '-fanart.jpg') 767 | return 768 | i = 1 769 | while i <= int(Config['proxy']['retry']): 770 | if os.path.getsize(path + '/' + number + c_word + '-fanart.jpg') == 0: 771 | print('[!]Image Download Failed! Trying again. ' + str(i) + '/' + Config['proxy']['retry']) 772 | self.DownloadFileWithFilename(cover, number + c_word + '-fanart.jpg', path, Config, filepath, 773 | failed_folder) 774 | i = i + 1 775 | continue 776 | else: 777 | break 778 | self.add_text_main('[+]Fanart Downloaded! ' + number + c_word + '-fanart.jpg') 779 | 780 | def smallCoverDownload(self, path, number, imagecut, cover_small, c_word, option, Config, filepath, failed_folder): 781 | if imagecut == 3: 782 | self.DownloadFileWithFilename(cover_small, 'cover_small.jpg', path, Config, filepath, failed_folder) 783 | try: 784 | fp = open(path + '/cover_small.jpg', 'rb') 785 | img = Image.open(fp) 786 | w = img.width 787 | h = img.height 788 | if int(w) >= int(h): 789 | self.add_text_main('[-]The size of cover_small.jpg is error, Try to cut fanart!') 790 | os.remove(path + '/cover_small.jpg') 791 | return 'small_cover_error' 792 | if option == 'emby': 793 | img.save(path + '/' + number + c_word + '.png') 794 | self.add_text_main('[+]Poster Downloaded! ' + number + c_word + '.png') 795 | elif option == 'kodi': 796 | img.save(path + '/' + number + c_word + '-poster.jpg') 797 | self.add_text_main('[+]Poster Downloaded! ' + number + c_word + '-poster.jpg') 798 | elif option == 'plex': 799 | img.save(path + '/poster.png') 800 | self.add_text_main('[+]Poster Downloaded! poster.png') 801 | time.sleep(1) 802 | fp.close() 803 | os.remove(path + '/cover_small.jpg') 804 | except Exception as error_info: 805 | self.add_text_main('[-]Error in smallCoverDownload: ' + str(error_info)) 806 | fp.close() 807 | os.remove(path + '/cover_small.jpg') 808 | self.add_text_main('[+]Try to cut fanart!') 809 | return 'small_cover_error' 810 | 811 | # ========================================================================打印NFO 812 | def PrintFiles(self, option, path, c_word, naming_rule, part, cn_sub, json_data, filepath, failed_folder): 813 | title, studio, year, outline, runtime, director, actor_photo, actor, release, tag, number, cover, website, label = get_info( 814 | json_data) 815 | name_title = naming_rule.replace('title', title).replace('studio', studio).replace('year', year).replace( 816 | 'runtime', 817 | runtime).replace( 818 | 'director', director).replace('actor', actor).replace('release', release).replace('number', number).replace( 819 | 'label', label) 820 | try: 821 | if not os.path.exists(path): 822 | os.makedirs(path) 823 | with open(path + "/" + number + part + c_word + ".nfo", "wt", encoding='UTF-8') as code: 824 | print('', file=code) 825 | print("", file=code) 826 | print(" " + name_title + part + "", file=code) 827 | print(" ", file=code) 828 | print(" ", file=code) 829 | print(" " + studio + "+", file=code) 830 | print(" " + year + "", file=code) 831 | print(" " + outline + "", file=code) 832 | print(" " + outline + "", file=code) 833 | print(" " + str(runtime).replace(" ", "") + "", file=code) 834 | print(" " + director + "", file=code) 835 | if option == 'emby': 836 | print(" " + number + part + c_word + ".png", file=code) 837 | print(" " + number + part + c_word + ".png", file=code) 838 | print(" " + number + part + c_word + '.jpg' + "", file=code) 839 | elif option == 'kodi': 840 | print(" " + number + part + c_word + "-poster.jpg", file=code) 841 | print(" " + number + part + c_word + '-fanart.jpg' + "", file=code) 842 | elif option == 'plex': 843 | print(" poster.png", file=code) 844 | print(" thumb.png", file=code) 845 | print(" fanart.jpg", file=code) 846 | try: 847 | for key, value in actor_photo.items(): 848 | print(" ", file=code) 849 | print(" " + key + "", file=code) 850 | if not value == '': # or actor_photo == []: 851 | print(" " + value + "", file=code) 852 | print(" ", file=code) 853 | except Exception as error_info: 854 | self.add_text_main('[-]Error in actor_photo: ' + str(error_info)) 855 | print(" " + studio + "", file=code) 856 | print(" ", file=code) 858 | print(" " + label + "", file=code) 859 | if cn_sub == '1': 860 | print(" 中文字幕", file=code) 861 | try: 862 | for i in tag: 863 | if i != '': 864 | print(" " + i + "", file=code) 865 | except Exception as error_info: 866 | self.add_text_main('[-]Error in tag: ' + str(error_info)) 867 | try: 868 | for i in tag: 869 | if i != '': 870 | print(" " + i + "", file=code) 871 | except Exception as error_info: 872 | self.add_text_main('[-]Error in genre: ' + str(error_info)) 873 | print(" " + label + "", file=code) 874 | if cn_sub == '1': 875 | print(" 中文字幕", file=code) 876 | print(" " + number + "", file=code) 877 | if option == 'emby': 878 | print(" " + release + "", file=code) 879 | elif option == 'kodi' or option == 'plex': 880 | print(" " + release + "", file=code) 881 | print(" " + cover + "", file=code) 882 | print(" " + website + "", file=code) 883 | print("", file=code) 884 | self.add_text_main("[+]Nfo Writed! " + number + part + c_word + ".nfo") 885 | except IOError as e: 886 | self.add_text_main("[-]Write Failed!") 887 | self.add_text_main('[-]Error in PrintFiles: ' + str(e)) 888 | self.moveFailedFolder(filepath, failed_folder) 889 | except Exception as error_info: 890 | self.add_text_main("[-]Write Failed!") 891 | self.add_text_main('[-]Error in PrintFiles: ' + str(error_info)) 892 | self.moveFailedFolder(filepath, failed_folder) 893 | 894 | def cutImage(self, option, imagecut, path, number, c_word): 895 | if option == 'plex': 896 | if imagecut == 1: 897 | try: 898 | img = Image.open(path + '/fanart.jpg') 899 | imgSize = img.size 900 | w = img.width 901 | h = img.height 902 | img2 = img.crop((w / 1.9, 0, w, h)) 903 | img2.save(path + '/poster.png') 904 | self.add_text_main('[+]Poster Cut! ' + 'poster.png') 905 | except: 906 | self.add_text_main('[-]Cover cut failed!') 907 | elif imagecut == 0: 908 | self.image_cut(path, 'fanart.jpg') 909 | elif option == 'emby': 910 | if imagecut == 1: 911 | try: 912 | img = Image.open(path + '/' + number + c_word + '.jpg') 913 | imgSize = img.size 914 | w = img.width 915 | h = img.height 916 | img2 = img.crop((w / 1.9, 0, w, h)) 917 | img2.save(path + '/' + number + c_word + '.png') 918 | self.add_text_main('[+]Poster Cut! ' + number + c_word + '.png') 919 | except: 920 | self.add_text_main('[-]Cover cut failed!') 921 | elif imagecut == 0: 922 | self.image_cut(path, number + c_word + '.jpg') 923 | elif option == 'kodi': 924 | if imagecut == 1: 925 | try: 926 | img = Image.open(path + '/' + number + c_word + '-fanart.jpg') 927 | imgSize = img.size 928 | w = img.width 929 | h = img.height 930 | img2 = img.crop((w / 1.9, 0, w, h)) 931 | img2.save(path + '/' + number + c_word + '-poster.jpg') 932 | self.add_text_main('[+]Poster Cut! ' + number + c_word + '-poster.jpg') 933 | except: 934 | self.add_text_main('[-]Cover cut failed!') 935 | elif imagecut == 0: 936 | self.image_cut(path, number + c_word + '-fanart.jpg') 937 | 938 | def copyRenameJpgToBackdrop(self, option, path, number, c_word): 939 | if option == 'plex': 940 | shutil.copy(path + '/fanart.jpg', path + '/Backdrop.jpg') 941 | shutil.copy(path + '/poster.png', path + '/thumb.png') 942 | if option == 'emby': 943 | shutil.copy(path + '/' + number + c_word + '.jpg', path + '/Backdrop.jpg') 944 | if option == 'kodi': 945 | shutil.copy(path + '/' + number + c_word + '-fanart.jpg', path + '/Backdrop.jpg') 946 | 947 | def pasteFileToFolder(self, filepath, path, number, c_word, config): # 文件路径,番号,后缀,要移动至的位置 948 | houzhui = str( 949 | re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group()) 950 | try: 951 | if config['common']['soft_link'] == '1': # 如果soft_link=1 使用软链接 952 | os.symlink(filepath, path + '/' + number + c_word + houzhui) 953 | self.add_text_main('[+]Movie Linked! ' + number + c_word + houzhui) 954 | else: 955 | os.rename(filepath, path + '/' + number + c_word + houzhui) 956 | self.add_text_main('[+]Movie Moved! ' + number + c_word + houzhui) 957 | if os.path.exists(os.getcwd() + '/' + number + c_word + '.srt'): # 字幕移动 958 | os.rename(os.getcwd() + '/' + number + c_word + '.srt', path + '/' + number + c_word + '.srt') 959 | self.add_text_main('[+]Sub moved!') 960 | elif os.path.exists(os.getcwd() + '/' + number + c_word + '.ssa'): 961 | os.rename(os.getcwd() + '/' + number + c_word + '.ssa', path + '/' + number + c_word + '.ssa') 962 | self.add_text_main('[+]Sub moved!') 963 | elif os.path.exists(os.getcwd() + '/' + number + c_word + '.sub'): 964 | os.rename(os.getcwd() + '/' + number + c_word + '.sub', path + '/' + number + c_word + '.sub') 965 | self.add_text_main('[+]Sub moved!') 966 | except FileExistsError: 967 | self.add_text_main('[-]Error in pasteFileToFolder_mode2! File Exists! Please check your movie!') 968 | except PermissionError: 969 | self.add_text_main('[-]Error in pasteFileToFolder_mode2! Please run as administrator!') 970 | 971 | def pasteFileToFolder_mode2(self, filepath, path, number, part, c_word, config): # 文件路径,番号,后缀,要移动至的位置 972 | houzhui = str( 973 | re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group()) 974 | try: 975 | if config['common']['soft_link'] == '1': 976 | os.symlink(filepath, path + '/' + number + c_word + houzhui) 977 | self.add_text_main('[+]Movie Linked! ' + number + c_word + houzhui) 978 | else: 979 | os.rename(filepath, path + '/' + number + c_word + houzhui) 980 | self.add_text_main('[+]Movie Moved! ' + number + c_word + houzhui) 981 | if os.path.exists(number + '.srt'): # 字幕移动 982 | os.rename(number + part + c_word + '.srt', path + '/' + number + c_word + '.srt') 983 | self.add_text_main('[+]Sub moved!') 984 | elif os.path.exists(number + part + c_word + '.ass'): 985 | os.rename(number + part + c_word + '.ass', path + '/' + number + c_word + '.ass') 986 | self.add_text_main('[+]Sub moved!') 987 | elif os.path.exists(number + part + c_word + '.sub'): 988 | os.rename(number + part + c_word + '.sub', path + '/' + number + c_word + '.sub') 989 | self.add_text_main('[+]Sub moved!') 990 | self.add_text_main('[!]Success') 991 | except FileExistsError: 992 | self.add_text_main('[-]Error in pasteFileToFolder_mode2! File Exists! Please check your movie!') 993 | except PermissionError: 994 | self.add_text_main('[-]Error in pasteFileToFolder_mode2! Please run as administrator!') 995 | 996 | def get_part(self, filepath, failed_folder): 997 | try: 998 | if re.search('-CD\d+', filepath): 999 | return re.findall('-CD\d+', filepath)[0] 1000 | if re.search('-cd\d+', filepath): 1001 | return re.findall('-cd\d+', filepath)[0] 1002 | except Exception as error_info: 1003 | self.add_text_main('[-]Error in get_part: ' + str(error_info)) 1004 | self.moveFailedFolder(filepath, failed_folder) 1005 | 1006 | # ========================================================================更新进度条 1007 | def set_processbar(self, value): 1008 | self.Ui.progressBar_avdc.setProperty("value", value) 1009 | self.Ui.label_percent.setText(str(value) + '%') 1010 | 1011 | # ========================================================================输出调试信息 1012 | def debug_mode(self, json_data, config): 1013 | try: 1014 | self.add_text_main('[+] ---Debug info---') 1015 | for key, value in json_data.items(): 1016 | if key == 'title' and value == '': 1017 | self.add_text_main(' [+]Title is None, Not Find Info!') 1018 | break 1019 | if value == '' or key == 'actor_photo': 1020 | continue 1021 | if key == 'tag': 1022 | value = str(json_data['tag']).strip(" ['']").replace('\'', '') 1023 | self.add_text_main(' [+]-' + "%-13s" % key + ': ' + str(value)) 1024 | self.add_text_main('[+] ---Debug info---') 1025 | except Exception as error_info: 1026 | self.add_text_main('[-]Error in debug_mode: ' + str(error_info)) 1027 | 1028 | # ========================================================================创建输出文件夹 1029 | def creatFolder(self, success_folder, json_data, config): 1030 | title, studio, year, outline, runtime, director, actor_photo, actor, release, tag, number, cover, website, label = get_info( 1031 | json_data) 1032 | if len(actor.split(',')) >= 15: 1033 | actor = actor.split(',')[0] + ',' + actor.split(',')[1] + ',' + actor.split(',')[2] + '等演员' 1034 | location_rule = json_data['location_rule'] 1035 | path = location_rule.replace('title', title).replace('studio', studio).replace('year', year).replace('runtime', 1036 | runtime).replace( 1037 | 'director', director).replace('actor', actor).replace('release', release).replace('number', number).replace( 1038 | 'label', label) 1039 | path = path.replace('//', '/') 1040 | if len(path) > 200: 1041 | self.add_text_main('[-]Error in Length of Path! Repleaced with actor/number') 1042 | path = actor + '/' + json_data['number'] 1043 | path = success_folder + '/' + path 1044 | if not os.path.exists(path): 1045 | path = escapePath(path, config) 1046 | try: 1047 | os.makedirs(path) 1048 | except Exception as error_info: 1049 | self.add_text_main('[-]Error in creatFolder: ' + str(error_info)) 1050 | return 'error' 1051 | return path 1052 | 1053 | # ========================================================================从指定网站获取json_data 1054 | def get_json_data(self, mode, number, config): 1055 | if (mode == 0 and self.Ui.radioButton_all.isChecked()) or mode == 1: 1056 | json_data = getDataFromJSON(number, config, 1) # 所有网站 1057 | elif (mode == 0 and self.Ui.radioButton_javdb.isChecked()) or mode == 2: 1058 | self.add_text_main('[!]Please Wait Three Seconds!') 1059 | time.sleep(3) 1060 | json_data = getDataFromJSON(number, config, 2) # 仅javdb 1061 | else: 1062 | json_data = getDataFromJSON(number, config, mode) # 仅javbus或仅avsox或仅fc2club或仅fanza或仅siro 1063 | return json_data 1064 | 1065 | # ========================================================================json_data添加到主界面 1066 | def add_label_info(self, json_data): 1067 | self.Ui.label_number.setText(json_data['number']) 1068 | self.Ui.label_release.setText(json_data['release']) 1069 | self.Ui.label_director.setText(json_data['director']) 1070 | self.Ui.label_runtime.setText(json_data['runtime']) 1071 | self.Ui.label_studio.setText(json_data['studio']) 1072 | self.Ui.label_label.setText(json_data['label']) 1073 | self.Ui.label_title.setText(json_data['title']) 1074 | self.Ui.label_actor.setText(json_data['actor']) 1075 | self.Ui.label_outline.setText(json_data['outline']) 1076 | self.Ui.label_tag.setText(str(json_data['tag']).strip(" [',']").replace('\'', '')) 1077 | if self.Ui.checkBox_cover.isChecked(): 1078 | fanart_path = json_data['fanart_path'] 1079 | poster_path = json_data['poster_path'] 1080 | if os.path.exists(fanart_path): 1081 | pix = QPixmap(fanart_path) 1082 | self.Ui.label_fanart.setScaledContents(True) 1083 | self.Ui.label_fanart.setPixmap(pix) # 添加缩略图 1084 | if os.path.exists(poster_path): 1085 | pix = QPixmap(poster_path) 1086 | self.Ui.label_poster.setScaledContents(True) 1087 | self.Ui.label_poster.setPixmap(pix) # 添加封面图 1088 | 1089 | 1090 | def Core_Main(self, file_path, number_th, mode, count): 1091 | # =======================================================================初始化所需变量 1092 | multi_part = 0 1093 | part = '' 1094 | c_word = '' 1095 | option = '' 1096 | cn_sub = '' 1097 | filepath = file_path # 影片的路径 1098 | number = number_th.replace('_', '-') 1099 | config_file = 'config.ini' 1100 | Config = ConfigParser() 1101 | Config.read(config_file, encoding='UTF-8') 1102 | try: 1103 | option = ReadMediaWarehouse(Config) 1104 | except Exception as error_info: 1105 | self.add_text_main('[-]Error in Core_Main: ' + str(error_info)) 1106 | program_mode = Config['common']['main_mode'] # 运行模式 1107 | failed_folder = Config['common']['failed_output_folder'] # 失败输出目录 1108 | success_folder = Config['common']['success_output_folder'] # 成功输出目录 1109 | # =======================================================================获取json_data 1110 | json_data = self.get_json_data(mode, number, Config) 1111 | # =======================================================================是否找到影片信息 1112 | if json_data['website'] == 'timeout': 1113 | self.add_text_main('[-]Connect Failed! Please check your Proxy or Network!') 1114 | return '' 1115 | elif self.Ui.radioButton_javdb.isChecked() and json_data['actor'] == 'N/A': 1116 | self.add_text_main('[-]Your IP Has Been Blocked By JAVDB!') 1117 | return '' 1118 | elif json_data['title'] == '': 1119 | self.add_text_main('[-]Movie Data not found!') 1120 | node = QTreeWidgetItem(self.item_fail) 1121 | node.setText(0, str(count) + '.' + os.path.splitext(filepath.split('/')[-1])[0]) 1122 | self.item_fail.addChild(node) 1123 | self.moveFailedFolder(filepath, failed_folder) 1124 | return 'not found' 1125 | # =======================================================================调试模式 1126 | if self.Ui.radioButton_debug_on.isChecked(): 1127 | self.debug_mode(json_data, Config) 1128 | # =======================================================================判断-C,-CD后缀 1129 | if '-CD' in filepath or '-cd' in filepath: 1130 | multi_part = 1 1131 | part = self.get_part(filepath, failed_folder) 1132 | if '-c.' in filepath or '-C.' in filepath or '中文' in filepath or '字幕' in filepath: 1133 | cn_sub = '1' 1134 | c_word = '-C' # 中文字幕影片后缀 1135 | # =======================================================================创建输出文件夹 1136 | self.CreatFailedFolder(failed_folder) # 创建输出失败目录 1137 | path = self.creatFolder(success_folder, json_data, Config) # 创建文件夹 1138 | if path == 'error': 1139 | node = QTreeWidgetItem(self.item_fail) 1140 | node.setText(0, str(count) + '.' + os.path.splitext(filepath.split('/')[-1])[0]) 1141 | self.item_fail.addChild(node) 1142 | self.moveFailedFolder(filepath, failed_folder) 1143 | return 1144 | self.add_text_main('[+]Folder : ' + path) 1145 | self.add_text_main('[+]From : ' + json_data['website']) 1146 | # =======================================================================刮削模式 1147 | number = json_data['number'] 1148 | if multi_part == 1: 1149 | number += part # 这时number会被附加上-CDx后缀 1150 | if program_mode == '1': 1151 | # imagecut 1 裁剪右半面,0 裁剪缩略图为封面,3 下载小封面 1152 | self.fanartDownload(option, json_data['cover'], number, c_word, path, multi_part, Config, filepath, 1153 | failed_folder) 1154 | if self.smallCoverDownload(path, number, json_data['imagecut'], json_data['cover_small'], c_word, option, 1155 | Config, filepath, failed_folder) == 'small_cover_error': # 检查小封面 1156 | json_data['imagecut'] = 0 1157 | self.cutImage(option, json_data['imagecut'], path, number, c_word) # 裁剪图 1158 | self.copyRenameJpgToBackdrop(option, path, number, c_word) 1159 | self.PrintFiles(option, path, c_word, json_data['naming_rule'], part, cn_sub, json_data, filepath, 1160 | failed_folder) # 打印文件 1161 | self.pasteFileToFolder(filepath, path, number, c_word, Config) # 移动文件 1162 | # =======================================================================整理模式 1163 | elif program_mode == '2': 1164 | self.pasteFileToFolder_mode2(filepath, path, number, part, c_word, Config) # 移动文件 1165 | # =======================================================================json添加封面项 1166 | fanart_path = '' 1167 | poster_path = '' 1168 | if self.Ui.radioButton_emby.isChecked(): # emby/jellyfin 1169 | fanart_path = path + '/' + number + c_word + '.jpg' 1170 | poster_path = path + '/' + number + c_word + '.png' 1171 | elif self.Ui.radioButton_plex.isChecked(): # plex 1172 | fanart_path = path + '/fanart.jpg' 1173 | poster_path = path + '/poster.png' 1174 | elif self.Ui.radioButton_kodi.isChecked(): # kodi 1175 | fanart_path = path + '/' + number + c_word + '-fanart.jpg' 1176 | poster_path = path + '/' + number + c_word + '-poster.jpg' 1177 | json_data['fanart_path'] = fanart_path 1178 | json_data['poster_path'] = poster_path 1179 | json_data['number'] = number 1180 | self.add_label_info(json_data) 1181 | self.json_array[str(count)] = json_data 1182 | 1183 | # ========================================================================AVDC刮削主功能 1184 | def UpdateCheck(self): 1185 | if self.Ui.radioButton_update_on.isChecked(): 1186 | check = 1 1187 | self.add_text_main('[!]Update Checking!') 1188 | else: 1189 | check = 0 1190 | if UpdateCheckSwitch(check) == '1': 1191 | html2 = get_html('https://raw.githubusercontent.com/moyy996/AVDC/master/update_check.json') 1192 | if html2 == 'ProxyError': 1193 | return 'ProxyError' 1194 | html = json.loads(str(html2)) 1195 | if float(self.version) < float(html['version']): 1196 | self.add_text_main('[*] * New update ' + html['version'] + ' *') 1197 | self.add_text_main('[*] ↓ Download ↓') 1198 | self.add_text_main('[*] ' + html['download']) 1199 | else: 1200 | self.add_text_main('[!]No Newer Version Available!') 1201 | return 'True' 1202 | 1203 | def CreatFailedFolder(self, failed_folder): 1204 | if not os.path.exists(failed_folder + '/'): # 新建failed文件夹 1205 | try: 1206 | os.makedirs(failed_folder + '/') 1207 | except Exception as error_info: 1208 | self.add_text_main('[-]Error in CreatFailedFolder: ' + str(error_info)) 1209 | 1210 | def CEF(self, path): 1211 | dirs = os.listdir(path) # 获取路径下的子文件(夹)列表 1212 | for dir in dirs: 1213 | try: 1214 | os.removedirs(path + '/' + dir) # 删除这个空文件夹 1215 | self.add_text_main('[+]Deleting empty folder' + path + '/' + dir) 1216 | except: 1217 | print('[+]Deleting empty folder error!') 1218 | 1219 | def AVDC_Main(self): 1220 | # =======================================================================初始化所需变量 1221 | config_file = 'config.ini' 1222 | config = ConfigParser() 1223 | config.read(config_file, encoding='UTF-8') 1224 | success_folder = config['common']['success_output_folder'] 1225 | failed_folder = config['common']['failed_output_folder'] # 失败输出目录 1226 | escape_folder = config['escape']['folders'] # 多级目录刮削需要排除的目录 1227 | # =======================================================================检测更新,判断网络情况,新建failed目录,获取影片列表 1228 | os.chdir(os.getcwd()) 1229 | if self.UpdateCheck() == 'ProxyError': 1230 | self.add_text_main('[-]Connect Failed! Please check your Proxy or Network!') 1231 | self.Ui.pushButton_start_cap.setEnabled(True) 1232 | self.add_text_main("[*]======================================================") 1233 | return 1234 | self.CreatFailedFolder(failed_folder) # 新建failed文件夹 1235 | movie_list = movie_lists(escape_folder) # 获取所有需要刮削的影片列表 1236 | count = 0 1237 | count_all = str(len(movie_list)) 1238 | self.add_text_main("[*]======================================================") 1239 | self.add_text_main('[+]Find ' + count_all + ' movies') 1240 | if config['common']['soft_link'] == '1': 1241 | self.add_text_main('[!] --- Soft link mode is ENABLE! ----') 1242 | # =======================================================================遍历电影列表 交给core处理 1243 | for movie in movie_list: # 遍历电影列表 交给core处理 1244 | count += 1 1245 | self.Ui.label_progress.setText(str(count) + '/' + str(count_all)) 1246 | percentage = str(count / int(count_all) * 100)[:4] + '%' 1247 | value = int(count / int(count_all) * 100) 1248 | self.progressBarValue.emit(int(value)) 1249 | self.add_text_main('[!] - ' + percentage + ' [' + str(count) + '/' + count_all + '] -') 1250 | try: 1251 | self.add_text_main("[!]Making Data for [" + movie + "], the number is [" + getNumber(movie) + "]") 1252 | if self.Core_Main(movie, getNumber(movie), 0, count) != 'not found': 1253 | node = QTreeWidgetItem(self.item_succ) 1254 | node.setText(0, str(count) + '.' + os.path.splitext(movie.split('/')[-1])[0]) 1255 | self.item_succ.addChild(node) 1256 | self.add_text_main("[*]======================================================") 1257 | except Exception as error_info: 1258 | node = QTreeWidgetItem(self.item_fail) 1259 | node.setText(0, str(count) + '.' + os.path.splitext(movie.split('/')[-1])[0]) 1260 | self.item_fail.addChild(node) 1261 | self.add_text_main('[-]Error in AVDC_Main: ' + str(error_info)) 1262 | curr_path = str(os.getcwd()).replace('\\', '/') 1263 | if config['common']['soft_link'] == '1': 1264 | self.add_text_main('[-]Link ' + movie + ' to failed folder') 1265 | try: 1266 | os.symlink(movie, curr_path + '/' + 'failed/') 1267 | except Exception as error_info: 1268 | self.add_text_main('[-]Error in AVDC_Main: ' + str(error_info)) 1269 | else: 1270 | try: 1271 | shutil.move(movie, curr_path + '/' + 'failed/') 1272 | self.add_text_main('[-]Move ' + movie + ' to failed folder') 1273 | except shutil.Error as error_info: 1274 | self.add_text_main('[-]Error in AVDC_Main: ' + str(error_info)) 1275 | self.add_text_main("[*]======================================================") 1276 | continue 1277 | self.Ui.pushButton_start_cap.setEnabled(True) 1278 | self.CEF(success_folder) 1279 | self.add_text_main("[+]All finished!!!") 1280 | 1281 | 1282 | if __name__ == '__main__': 1283 | ''' 1284 | 主函数 1285 | ''' 1286 | app = QApplication(sys.argv) 1287 | ui = MyMAinWindow() 1288 | ui.show() 1289 | sys.exit(app.exec_()) 1290 | --------------------------------------------------------------------------------