Skip to content

Commit

Permalink
use poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
glyh committed Apr 16, 2024
1 parent 73cd818 commit 0de611c
Show file tree
Hide file tree
Showing 143 changed files with 3,095 additions and 167 deletions.
722 changes: 722 additions & 0 deletions data/LICENSE

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## JavSp-meta

本Repo维护用于[JavSP](https://github.com/Yuukiy/JavSP)的元数据。欢迎贡献。
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions javsp/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from javsp import cli

if __name__ == "__main__":
cli.main()
25 changes: 13 additions & 12 deletions JavSP.py → javsp/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
pretty_errors.configure(display_link=True)


from core.print import TqdmOut
from javsp.core.print import TqdmOut


# 将StreamHandler的stream修改为TqdmOut,以与Tqdm协同工作
Expand All @@ -32,20 +32,21 @@
logger = logging.getLogger('main')


from core.lib import mei_path
from core.nfo import write_nfo
from core.config import cfg, args
from core.file import *
from core.func import *
from core.image import *
from core.datatype import Movie, MovieInfo
from javsp.core.lib import mei_path
from javsp.core.nfo import write_nfo
from javsp.core.config import cfg, args
from javsp.core.file import *
from javsp.core.func import *
from javsp.core.image import *
from javsp.core.datatype import Movie, MovieInfo
from web.base import download
from web.exceptions import *
from web.translate import translate_movie_info

actressAliasMap = {}
if cfg.NFO.fix_actress_name:
actressAliasFilePath = mei_path("data/actress_alias.json")

actressAliasFilePath = mei_path("data/aliases/ja_JP/actress_alias.json")
with open(actressAliasFilePath, "r", encoding="utf-8") as file:
actressAliasMap = json.load(file)

Expand Down Expand Up @@ -439,15 +440,15 @@ def reviewMovieID(all_movies, root):
def crop_poster_wrapper(fanart_file, poster_file, method='normal', hard_sub=False):
"""包装各种海报裁剪方法,提供统一的调用"""
if method == 'baidu':
from core.ai_crop.baidu_aip import aip_crop_poster
from javsp.core.ai_crop.baidu_aip import aip_crop_poster
try:
aip_crop_poster(fanart_file, poster_file)
except Exception as e:
logger.debug('人脸识别失败,回退到常规裁剪方法')
logger.debug(e, exc_info=True)
crop_poster(fanart_file, poster_file)
elif method == 'retina':
from core.ai_crop.retina import ai_crop_poster
from javsp.core.ai_crop.retina import ai_crop_poster
try:
ai_crop_poster(fanart_file, poster_file)
except Exception as e:
Expand Down Expand Up @@ -636,7 +637,7 @@ def only_fetch():
file.write(json_str) # 将数据写入文件
return 0

if __name__ == "__main__":
def main():
colorama.init(autoreset=True)
# python版本检查
import platform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from PIL import Image, ImageDraw, ImageFont, ImageOps

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from core.config import cfg, rel_path_from_exe
from javsp.core.config import cfg, rel_path_from_exe

logger = logging.getLogger(__name__)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion core/avid.py → javsp/core/avid.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from core.config import cfg
from javsp.core.config import cfg


def get_id(filepath: str) -> str:
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions core/config.py → javsp/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from shutil import copyfile
from string import Template

from .lib import re_escape
from .lib import re_escape, mei_path

__all__ = ['cfg', 'args', 'is_url']

if getattr(sys, 'frozen', False):
built_in_cfg_file = os.path.join(sys._MEIPASS, 'config.ini')
built_in_cfg_file = mei_path('config.ini')
else:
built_in_cfg_file = os.path.join(os.path.dirname(__file__), 'config.ini')

Expand Down
2 changes: 1 addition & 1 deletion core/datatype.py → javsp/core/datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from functools import cached_property

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from core.lib import mei_path, detect_special_attr
from javsp.core.lib import mei_path, detect_special_attr


logger = logging.getLogger(__name__)
Expand Down
8 changes: 4 additions & 4 deletions core/file.py → javsp/core/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@


sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from core.avid import *
from core.lib import re_escape
from core.config import cfg
from core.datatype import Movie
from javsp.core.avid import *
from javsp.core.lib import re_escape
from javsp.core.config import cfg
from javsp.core.datatype import Movie

logger = logging.getLogger(__name__)
failed_items = []
Expand Down
2 changes: 1 addition & 1 deletion core/func.py → javsp/core/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import *
from core.lib import mei_path, re_escape
from javsp.core.lib import mei_path, re_escape


__all__ = ['select_folder', 'get_scan_dir', 'remove_trail_actor_in_title',
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion core/lib.py → javsp/core/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def re_escape(s: str) -> str:
def mei_path(path):
"""获取一个随代码打包的文件在解压后的路径"""
if getattr(sys, 'frozen', False):
return os.path.join(sys._MEIPASS, path)
mei_path = getattr(sys, '_MEIPASS', os.path.dirname(sys.executable))
return os.path.join(mei_path, path)
else:
return path

Expand Down
4 changes: 2 additions & 2 deletions core/nfo.py → javsp/core/nfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@


sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from core.datatype import MovieInfo
from core.config import cfg
from javsp.core.datatype import MovieInfo
from javsp.core.config import cfg


def write_nfo(info: MovieInfo, nfo_file):
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions web/airav.py → javsp/web/airav.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import Request
from web.exceptions import *
from core.config import cfg
from core.datatype import MovieInfo
from javsp.core.config import cfg
from javsp.core.datatype import MovieInfo

# 初始化Request实例
request = Request(use_scraper=True)
Expand Down
4 changes: 2 additions & 2 deletions web/avsox.py → javsp/web/avsox.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import get_html
from web.exceptions import *
from core.config import cfg
from core.datatype import MovieInfo
from javsp.core.config import cfg
from javsp.core.datatype import MovieInfo


logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion web/avwiki.py → javsp/web/avwiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import *
from web.exceptions import *
from core.datatype import MovieInfo
from javsp.core.datatype import MovieInfo

logger = logging.getLogger(__name__)
base_url = 'https://av-wiki.net'
Expand Down
2 changes: 1 addition & 1 deletion web/base.py → javsp/web/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from core.config import cfg
from javsp.core.config import cfg


__all__ = ['Request', 'get_html', 'post_html', 'request_get', 'resp2html', 'is_connectable', 'download', 'get_resp_text']
Expand Down
2 changes: 1 addition & 1 deletion web/dl_getchu.py → javsp/web/dl_getchu.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import resp2html, request_get
from web.exceptions import *
from core.datatype import MovieInfo
from javsp.core.datatype import MovieInfo

logger = logging.getLogger(__name__)

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions web/fanza.py → javsp/web/fanza.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import Request, resp2html
from web.exceptions import *
from core.config import cfg
from core.datatype import MovieInfo
from javsp.core.config import cfg
from javsp.core.datatype import MovieInfo


logger = logging.getLogger(__name__)
Expand Down
6 changes: 3 additions & 3 deletions web/fc2.py → javsp/web/fc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import get_html, request_get
from web.exceptions import *
from core.config import cfg
from core.lib import strftime_to_minutes
from core.datatype import MovieInfo
from javsp.core.config import cfg
from javsp.core.lib import strftime_to_minutes
from javsp.core.datatype import MovieInfo


logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions web/fc2fan.py → javsp/web/fc2fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import resp2html
from web.exceptions import *
from core.config import cfg
from core.datatype import MovieInfo
from javsp.core.config import cfg
from javsp.core.datatype import MovieInfo


logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion web/gyutto.py → javsp/web/gyutto.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import resp2html, request_get
from web.exceptions import *
from core.datatype import MovieInfo
from javsp.core.datatype import MovieInfo

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion web/jav321.py → javsp/web/jav321.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import post_html
from web.exceptions import *
from core.datatype import MovieInfo
from javsp.core.datatype import MovieInfo


logger = logging.getLogger(__name__)
Expand Down
8 changes: 4 additions & 4 deletions web/javbus.py → javsp/web/javbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import *
from web.exceptions import *
from core.func import *
from core.config import cfg
from core.datatype import MovieInfo, GenreMap
from javsp.core.func import *
from javsp.core.config import cfg
from javsp.core.datatype import MovieInfo, GenreMap


logger = logging.getLogger(__name__)
genre_map = GenreMap('data/genre_javbus.csv')
genre_map = GenreMap('data/genres/javbus.csv')
permanent_url = 'https://www.javbus.com'
if cfg.Network.proxy:
base_url = permanent_url
Expand Down
14 changes: 7 additions & 7 deletions web/javdb.py → javsp/web/javdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import Request, resp2html
from web.exceptions import *
from core.func import *
from core.avid import guess_av_type
from core.config import cfg
from core.datatype import MovieInfo, GenreMap
from core.chromium import get_browsers_cookies
from javsp.core.func import *
from javsp.core.avid import guess_av_type
from javsp.core.config import cfg
from javsp.core.datatype import MovieInfo, GenreMap
from javsp.core.chromium import get_browsers_cookies


# 初始化Request实例。使用scraper绕过CloudFlare后,需要指定网页语言,否则可能会返回其他语言网页,影响解析
request = Request(use_scraper=True)
request.headers['Accept-Language'] = 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en-US;q=0.7,en;q=0.6,ja;q=0.5'

logger = logging.getLogger(__name__)
genre_map = GenreMap('data/genre_javdb.csv')
genre_map = GenreMap('data/genres/javdb.csv')
permanent_url = 'https://javdb.com'
if cfg.Network.proxy:
base_url = permanent_url
Expand Down Expand Up @@ -231,7 +231,7 @@ def collect_actress_alias(type=0, use_original=True):

actressAliasMap = {}

actressAliasFilePath = "data/actress_alias.json"
actressAliasFilePath = "data/aliases/ja_JP/actress_alias.json"
# 检查文件是否存在
if not os.path.exists(actressAliasFilePath):
# 如果文件不存在,创建文件并写入空字典
Expand Down
4 changes: 2 additions & 2 deletions web/javlib.py → javsp/web/javlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from web.base import Request, resp2html
from web.exceptions import *
from web.proxyfree import get_proxy_free_url
from core.config import cfg
from core.datatype import MovieInfo
from javsp.core.config import cfg
from javsp.core.datatype import MovieInfo


# 初始化Request实例
Expand Down
2 changes: 1 addition & 1 deletion web/javmenu.py → javsp/web/javmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import Request, resp2html
from web.exceptions import *
from core.datatype import MovieInfo
from javsp.core.datatype import MovieInfo


request = Request()
Expand Down
4 changes: 2 additions & 2 deletions web/mgstage.py → javsp/web/mgstage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import Request, resp2html
from web.exceptions import *
from core.config import cfg
from core.datatype import MovieInfo
from javsp.core.config import cfg
from javsp.core.datatype import MovieInfo


logger = logging.getLogger(__name__)
Expand Down
6 changes: 3 additions & 3 deletions web/msin.py → javsp/web/msin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import *
from web.exceptions import *
from core.config import cfg
from core.lib import strftime_to_minutes
from core.datatype import MovieInfo
from javsp.core.config import cfg
from javsp.core.lib import strftime_to_minutes
from javsp.core.datatype import MovieInfo


logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion web/prestige.py → javsp/web/prestige.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from web.base import *
from web.exceptions import *
from core.datatype import MovieInfo
from javsp.core.datatype import MovieInfo


logger = logging.getLogger(__name__)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions web/translate.py → javsp/web/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@


sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from core.config import cfg
from core.datatype import MovieInfo
from javsp.core.config import cfg
from javsp.core.datatype import MovieInfo


logger = logging.getLogger(__name__)
Expand Down
Loading

0 comments on commit 0de611c

Please sign in to comment.