commit
This commit is contained in:
BIN
helper/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
helper/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
helper/__pycache__/get_kakao_list.cpython-311.pyc
Normal file
BIN
helper/__pycache__/get_kakao_list.cpython-311.pyc
Normal file
Binary file not shown.
BIN
helper/__pycache__/missing_episode.cpython-311.pyc
Normal file
BIN
helper/__pycache__/missing_episode.cpython-311.pyc
Normal file
Binary file not shown.
BIN
helper/__pycache__/missing_images.cpython-311.pyc
Normal file
BIN
helper/__pycache__/missing_images.cpython-311.pyc
Normal file
Binary file not shown.
BIN
helper/__pycache__/prerequisite.cpython-311.pyc
Normal file
BIN
helper/__pycache__/prerequisite.cpython-311.pyc
Normal file
Binary file not shown.
18
helper/get_kakao_list.py
Normal file
18
helper/get_kakao_list.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from data.special_list import KAKAO_1, KAKAO_3, KAKAO_C, KAKAO_P, KAKAO_W
|
||||
|
||||
def get_kakao_id_list(input):
|
||||
|
||||
kakao_list = []
|
||||
|
||||
if "1" in input:
|
||||
kakao_list.extend(KAKAO_1)
|
||||
if "3" in input:
|
||||
kakao_list.extend(KAKAO_3)
|
||||
if "c" in input:
|
||||
kakao_list.extend(KAKAO_C)
|
||||
if "w" in input:
|
||||
kakao_list.extend(KAKAO_W)
|
||||
if "p" in input:
|
||||
kakao_list.extend(KAKAO_P)
|
||||
|
||||
return kakao_list
|
||||
62
helper/prerequisite.py
Normal file
62
helper/prerequisite.py
Normal file
@@ -0,0 +1,62 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
from data.path_constant import DOWNLOAD_DIR, NETWORK_DIR
|
||||
|
||||
# input: DOWNLOAD_DIR or NETWORK_DIR
|
||||
def delete_all_empty_episodes(path: Path):
|
||||
for first_level_path in path.iterdir():
|
||||
if first_level_path.is_dir():
|
||||
for second_level_path in first_level_path.iterdir():
|
||||
if second_level_path.is_dir() and not any(second_level_path.iterdir()):
|
||||
print(f"Deleting directory: {second_level_path}")
|
||||
shutil.rmtree(second_level_path)
|
||||
print(f"Empty directory '{second_level_path}' deleted successfully.")
|
||||
|
||||
|
||||
def delete_all_webtoons_without_episodes():
|
||||
for first_level_path in NETWORK_DIR.iterdir():
|
||||
if first_level_path.is_dir():
|
||||
contains_dir = any(item.is_dir() for item in first_level_path.iterdir())
|
||||
if not contains_dir:
|
||||
# No subdirectories, safe to delete
|
||||
print(f"Deleting directory: {first_level_path}")
|
||||
shutil.rmtree(first_level_path)
|
||||
print(f"Directory '{first_level_path}' deleted successfully.")
|
||||
|
||||
def get_download_list(path: Path):
|
||||
url_list = []
|
||||
try:
|
||||
with open(path, 'r', encoding='utf-8') as file:
|
||||
for url in file:
|
||||
if 'https://' in url:
|
||||
url_list.append(url.strip())
|
||||
except FileNotFoundError:
|
||||
print(f"The file at {path} was not found.")
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
return url_list
|
||||
|
||||
def rename_episodes(path: Path):
|
||||
for first_level_path in path.iterdir():
|
||||
if first_level_path.is_dir():
|
||||
for second_level_path in first_level_path.iterdir():
|
||||
if second_level_path.is_dir() and '. ' in second_level_path.name:
|
||||
print(second_level_path)
|
||||
newName = second_level_path.name.replace(". ", ".")
|
||||
new_path = first_level_path / newName
|
||||
os.rename(second_level_path, new_path)
|
||||
if second_level_path.is_dir() and '(' in second_level_path.name:
|
||||
print(second_level_path)
|
||||
newName = second_level_path.name.replace("(", " (")
|
||||
newName = newName.replace(")", ")")
|
||||
new_path = first_level_path / newName
|
||||
os.rename(second_level_path, new_path)
|
||||
|
||||
|
||||
def get_episodes_with_wrong_name(path: Path):
|
||||
for first_level_path in path.iterdir():
|
||||
if first_level_path.is_dir():
|
||||
for second_level_path in first_level_path.iterdir():
|
||||
if second_level_path.is_dir() and len(second_level_path.name.split('.')) > 2:
|
||||
print(second_level_path)
|
||||
Reference in New Issue
Block a user