Merge pull request #743 from lededev/rating-2

KODI评分显示投票人数
This commit is contained in:
Yoshiko2
2022-03-31 18:15:28 +08:00
committed by GitHub
3 changed files with 21 additions and 10 deletions

View File

@@ -175,7 +175,8 @@ def getSeries(html):
def getUserRating(html): def getUserRating(html):
try: try:
result = str(html.xpath('//span[@class="score-stars"]/../text()')[0]) result = str(html.xpath('//span[@class="score-stars"]/../text()')[0])
return result[:result.find('')].strip() v = re.findall(r'(\d+|\d+\.\d+)分, 由(\d+)人評價', result)
return float(v[0][0]), int(v[0][1])
except: except:
return return
@@ -302,8 +303,9 @@ def main(number):
} }
userrating = getUserRating(lx) userrating = getUserRating(lx)
if userrating: if isinstance(userrating, tuple) and len(userrating) == 2:
dic['userrating'] = userrating dic['用户评分'] = userrating[0]
dic['评分人数'] = userrating[1]
if not dic['actor'] and re.match(r'FC2-[\d]+', number, re.A): if not dic['actor'] and re.match(r'FC2-[\d]+', number, re.A):
dic['actor'].append('素人') dic['actor'].append('素人')
if not dic['series']: if not dic['series']:

View File

@@ -19,9 +19,10 @@ def getTitle(html): # 获取标题
# <title>MD0140-2 / 家有性事EP2 爱在身边-麻豆社</title> # <title>MD0140-2 / 家有性事EP2 爱在身边-麻豆社</title>
# <title>MAD039 机灵可爱小叫花 强诱僧人迫犯色戒-麻豆社</title> # <title>MAD039 机灵可爱小叫花 强诱僧人迫犯色戒-麻豆社</title>
# <title>MD0094贫嘴贱舌中出大嫂坏嫂嫂和小叔偷腥内射受孕-麻豆社</title> # <title>MD0094贫嘴贱舌中出大嫂坏嫂嫂和小叔偷腥内射受孕-麻豆社</title>
# <title>TM0002-我的痴女女友-麻豆社</title>
browser_title = str(html.xpath("/html/head/title/text()")[0]) browser_title = str(html.xpath("/html/head/title/text()")[0])
title = str(re.findall(r'^.*?( / | |)(.*)-麻豆社$', browser_title)[0][1]).strip() title = str(re.findall(r'^[A-Z0-9 /\-]*(.*)-麻豆社$', browser_title)[0]).strip()
return title.replace('', ' ') return title
def getStudio(html): # 获取厂商 已修改 def getStudio(html): # 获取厂商 已修改
try: try:
@@ -60,7 +61,6 @@ def getNum(url, number): # 获取番号
filename = unquote(urlparse(url).path) filename = unquote(urlparse(url).path)
# 裁剪文件名 # 裁剪文件名
result = filename[1:-5].upper().strip() result = filename[1:-5].upper().strip()
print(result)
# 移除中文 # 移除中文
if result.upper() != number.upper(): if result.upper() != number.upper():
result = re.split(r'[^\x00-\x7F]+', result, 1)[0] result = re.split(r'[^\x00-\x7F]+', result, 1)[0]
@@ -164,6 +164,8 @@ def main(number):
if __name__ == '__main__': if __name__ == '__main__':
config.G_conf_override['debug_mode:switch'] = True
print(main('TM0002'))
print(main('MD0222')) print(main('MD0222'))
print(main('MD0140-2')) print(main('MD0140-2'))
print(main('MAD039')) print(main('MAD039'))

15
core.py
View File

@@ -355,10 +355,17 @@ def print_files(path, leak_word, c_word, naming_rule, part, cn_sub, json_data, f
print(" <releasedate>" + release + "</releasedate>", file=code) print(" <releasedate>" + release + "</releasedate>", file=code)
print(" <release>" + release + "</release>", file=code) print(" <release>" + release + "</release>", file=code)
try: try:
f_rating = float(json_data['userrating']) f_rating = json_data['用户评分']
print(f" <userrating>{round(f_rating * 2.0)}</userrating>", file=code) uc = json_data['评分人数']
print(f" <rating>{round(f_rating * 2.0, 1)}</rating>", file=code) print(f""" <userrating>{round(f_rating * 2.0)}</userrating>
print(f" <criticrating>{round(f_rating * 20.0, 1)}</criticrating>", file=code) <rating>{round(f_rating * 2.0, 1)}</rating>
<criticrating>{round(f_rating * 20.0, 1)}</criticrating>
<ratings>
<rating name="javdb" max="5" default="true">
<value>{f_rating}</value>
<votes>{uc}</votes>
</rating>
</ratings>""", file=code)
except: except:
pass pass
print(" <cover>" + cover + "</cover>", file=code) print(" <cover>" + cover + "</cover>", file=code)