fix download none error
This commit is contained in:
+13
-2
@@ -1122,13 +1122,14 @@ class LogicLinkkf(object):
|
|||||||
# else:
|
# else:
|
||||||
# epi_no = '%.1f'%float(title)
|
# epi_no = '%.1f'%float(title)
|
||||||
# epi_no = "%s-pt1" % epi_no
|
# epi_no = "%s-pt1" % epi_no
|
||||||
epi_no = total_epi
|
epi_no = int(total_epi)
|
||||||
if epi_no < 10:
|
if epi_no < 10:
|
||||||
epi_no = "0%s" % epi_no
|
epi_no = "0%s" % epi_no
|
||||||
else:
|
else:
|
||||||
epi_no = "%s" % epi_no
|
epi_no = "%s" % epi_no
|
||||||
|
|
||||||
if int(season) < 10:
|
season = int(season)
|
||||||
|
if season < 10:
|
||||||
season = "0%s" % season
|
season = "0%s" % season
|
||||||
else:
|
else:
|
||||||
season = "%s" % season
|
season = "%s" % season
|
||||||
@@ -1144,6 +1145,16 @@ class LogicLinkkf(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Exception:%s", e)
|
logger.error("Exception:%s", e)
|
||||||
logger.error(traceback.format_exc())
|
logger.error(traceback.format_exc())
|
||||||
|
safe_title = Util.change_text_for_use_filename(str(maintitle or "linkkf")).strip() or "linkkf"
|
||||||
|
try:
|
||||||
|
safe_season = int(season)
|
||||||
|
except Exception:
|
||||||
|
safe_season = 1
|
||||||
|
try:
|
||||||
|
safe_epi = int(total_epi)
|
||||||
|
except Exception:
|
||||||
|
safe_epi = 1
|
||||||
|
return f"{safe_title}.S{safe_season:02d}E{safe_epi:02d}.720p-LK.mp4"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _extract_player_payload(html_text):
|
def _extract_player_payload(html_text):
|
||||||
|
|||||||
+34
-5
@@ -116,11 +116,35 @@ class LogicQueue(object):
|
|||||||
def _make_save_path(info):
|
def _make_save_path(info):
|
||||||
save_path = LogicQueue._get_setting("download_path", os.path.join(F.config["path_data"], "linkkf"))
|
save_path = LogicQueue._get_setting("download_path", os.path.join(F.config["path_data"], "linkkf"))
|
||||||
if LogicQueue._get_setting("auto_make_folder", "True") == "True":
|
if LogicQueue._get_setting("auto_make_folder", "True") == "True":
|
||||||
save_path = os.path.join(save_path, info["save_folder"])
|
save_folder = str(info.get("save_folder") or info.get("program_title") or info.get("program_code") or "linkkf").strip()
|
||||||
|
save_path = os.path.join(save_path, save_folder)
|
||||||
if LogicQueue._get_setting("linkkf_auto_make_season_folder", "True") == "True":
|
if LogicQueue._get_setting("linkkf_auto_make_season_folder", "True") == "True":
|
||||||
save_path = os.path.join(save_path, f"Season {int(info['season'])}")
|
try:
|
||||||
|
season = int(info.get("season") or 1)
|
||||||
|
except Exception:
|
||||||
|
season = 1
|
||||||
|
save_path = os.path.join(save_path, f"Season {season}")
|
||||||
return save_path
|
return save_path
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _ensure_download_info(info):
|
||||||
|
from .logic_linkkf import LogicLinkkf
|
||||||
|
|
||||||
|
if info.get("save_folder") in [None, ""]:
|
||||||
|
info["save_folder"] = str(
|
||||||
|
info.get("program_title") or info.get("program_code") or info.get("code") or "linkkf"
|
||||||
|
).strip()
|
||||||
|
if info.get("season") in [None, ""]:
|
||||||
|
info["season"] = "1"
|
||||||
|
if info.get("filename") in [None, ""]:
|
||||||
|
info["filename"] = LogicLinkkf.get_filename(
|
||||||
|
info.get("save_folder") or "linkkf",
|
||||||
|
info.get("season") or "1",
|
||||||
|
info.get("title") or info.get("code") or "episode",
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
return info
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _make_headers(video_info):
|
def _make_headers(video_info):
|
||||||
linkkf_url = str(LogicQueue._get_setting("linkkf_url", "https://linkkf.tv")).rstrip("/")
|
linkkf_url = str(LogicQueue._get_setting("linkkf_url", "https://linkkf.tv")).rstrip("/")
|
||||||
@@ -345,6 +369,7 @@ class LogicQueue(object):
|
|||||||
def _prepare_download(entity):
|
def _prepare_download(entity):
|
||||||
from .logic_linkkf import LogicLinkkf
|
from .logic_linkkf import LogicLinkkf
|
||||||
|
|
||||||
|
entity.info = LogicQueue._ensure_download_info(entity.info)
|
||||||
LogicQueue._ensure_db_entity(entity.info)
|
LogicQueue._ensure_db_entity(entity.info)
|
||||||
entity.url = LogicLinkkf.get_video_url(entity.info["url"])
|
entity.url = LogicLinkkf.get_video_url(entity.info["url"])
|
||||||
logger.debug("resolved video url: %s", entity.url)
|
logger.debug("resolved video url: %s", entity.url)
|
||||||
@@ -356,7 +381,10 @@ class LogicQueue(object):
|
|||||||
|
|
||||||
save_path = LogicQueue._make_save_path(entity.info)
|
save_path = LogicQueue._make_save_path(entity.info)
|
||||||
os.makedirs(save_path, exist_ok=True)
|
os.makedirs(save_path, exist_ok=True)
|
||||||
target_path = os.path.join(save_path, entity.info["filename"])
|
filename = entity.info.get("filename")
|
||||||
|
if filename in [None, ""]:
|
||||||
|
raise ValueError(f"missing filename for episode: {entity.info.get('code')}")
|
||||||
|
target_path = os.path.join(save_path, filename)
|
||||||
|
|
||||||
if os.path.exists(target_path):
|
if os.path.exists(target_path):
|
||||||
LogicQueue._set_entity_status(entity, 100, 100, {"percent": 100})
|
LogicQueue._set_entity_status(entity, 100, 100, {"percent": 100})
|
||||||
@@ -374,11 +402,12 @@ class LogicQueue(object):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
headers = LogicQueue._make_headers(entity.url)
|
headers = LogicQueue._make_headers(entity.url)
|
||||||
LogicQueue._download_subtitle(entity.url, save_path, entity.info["filename"], headers)
|
LogicQueue._download_subtitle(entity.url, save_path, filename, headers)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"video_url": entity.url[0],
|
"video_url": entity.url[0],
|
||||||
"save_path": save_path,
|
"save_path": save_path,
|
||||||
|
"filename": filename,
|
||||||
"headers": headers,
|
"headers": headers,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,7 +430,7 @@ class LogicQueue(object):
|
|||||||
|
|
||||||
ffmpeg_instance = SupportFfmpeg(
|
ffmpeg_instance = SupportFfmpeg(
|
||||||
prepared["video_url"],
|
prepared["video_url"],
|
||||||
entity.info["filename"],
|
prepared["filename"],
|
||||||
save_path=prepared["save_path"],
|
save_path=prepared["save_path"],
|
||||||
headers=prepared["headers"],
|
headers=prepared["headers"],
|
||||||
callback_id=str(entity.entity_id),
|
callback_id=str(entity.entity_id),
|
||||||
|
|||||||
Reference in New Issue
Block a user