Merge branch 'master' of https://github.com/yoshiko2/AV_Data_Capture
This commit is contained in:
@@ -17,6 +17,7 @@ retry=3
|
|||||||
[Name_Rule]
|
[Name_Rule]
|
||||||
location_rule=actor+'/'+number
|
location_rule=actor+'/'+number
|
||||||
naming_rule=number+'-'+title
|
naming_rule=number+'-'+title
|
||||||
|
max_title_len= 50
|
||||||
|
|
||||||
[update]
|
[update]
|
||||||
update_check=1
|
update_check=1
|
||||||
|
|||||||
10
config.py
10
config.py
@@ -52,6 +52,15 @@ class Config:
|
|||||||
|
|
||||||
def location_rule(self) -> str:
|
def location_rule(self) -> str:
|
||||||
return self.conf.get("Name_Rule", "location_rule")
|
return self.conf.get("Name_Rule", "location_rule")
|
||||||
|
|
||||||
|
def max_title_len(self) -> int:
|
||||||
|
"""
|
||||||
|
Maximum title length
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
return self.conf.getint("Name_Rule", "max_title_len")
|
||||||
|
except:
|
||||||
|
return 50
|
||||||
|
|
||||||
def update_check(self) -> bool:
|
def update_check(self) -> bool:
|
||||||
try:
|
try:
|
||||||
@@ -102,6 +111,7 @@ class Config:
|
|||||||
conf.add_section(sec3)
|
conf.add_section(sec3)
|
||||||
conf.set(sec3, "location_rule", "actor + '/' + number")
|
conf.set(sec3, "location_rule", "actor + '/' + number")
|
||||||
conf.set(sec3, "naming_rule", "number + '-' + title")
|
conf.set(sec3, "naming_rule", "number + '-' + title")
|
||||||
|
conf.set(sec3, "max_title_len", "50")
|
||||||
|
|
||||||
sec4 = "update"
|
sec4 = "update"
|
||||||
conf.add_section(sec4)
|
conf.add_section(sec4)
|
||||||
|
|||||||
6
core.py
6
core.py
@@ -196,8 +196,10 @@ def get_data_from_json(file_number, filepath, conf: config.Config): # 从JSON
|
|||||||
if 'actor' in conf.location_rule() and len(actor) > 100:
|
if 'actor' in conf.location_rule() and len(actor) > 100:
|
||||||
print(conf.location_rule())
|
print(conf.location_rule())
|
||||||
location_rule = eval(conf.location_rule().replace("actor","'多人作品'"))
|
location_rule = eval(conf.location_rule().replace("actor","'多人作品'"))
|
||||||
if 'title' in conf.location_rule() and len(title) > 100:
|
maxlen = conf.max_title_len()
|
||||||
location_rule = eval(conf.location_rule().replace("title",'number'))
|
if 'title' in conf.location_rule() and len(title) > maxlen:
|
||||||
|
shorttitle = title[0:maxlen]
|
||||||
|
location_rule = location_rule.replace(title, shorttitle)
|
||||||
|
|
||||||
# 返回处理后的json_data
|
# 返回处理后的json_data
|
||||||
json_data['title'] = title
|
json_data['title'] = title
|
||||||
|
|||||||
Reference in New Issue
Block a user