You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.3 KiB
44 lines
1.3 KiB
from config_local import Config
|
|
from jobdef import QueueItem
|
|
from minfo import MediaInfo
|
|
from pathlib import Path
|
|
import json
|
|
import os
|
|
|
|
extensions = {
|
|
"mp4",
|
|
"mkv",
|
|
"mpeg",
|
|
"mpg",
|
|
"m4v",
|
|
"avi",
|
|
"mov",
|
|
"wmv",
|
|
"flv",
|
|
}
|
|
|
|
jobs = []
|
|
for dir, dirs, files in os.walk(str(Config.BASE_PATH)):
|
|
for file in files:
|
|
parts = file.rsplit(".", 1)
|
|
if len(parts) == 2:
|
|
extension = parts[1].lower()
|
|
if extension in extensions:
|
|
current_path = Path(dir)
|
|
relative_path = current_path.relative_to(Config.BASE_PATH)
|
|
print(relative_path / file, end=" ")
|
|
item = QueueItem(Path(dir) / file, Config.DESTINATION_PATH / relative_path)
|
|
info = item.task.mediainfo
|
|
if info.codec == 'HEVC':
|
|
print("")
|
|
continue
|
|
if info.bitrate < Config.LOW_BITRATE_THRESHOLD:
|
|
print("")
|
|
continue
|
|
item.task.destination.parent.mkdir(exist_ok=True)
|
|
print(" ... added")
|
|
jobs.append(item)
|
|
|
|
with open("queue.json", "w") as fp:
|
|
json.dump(jobs, fp, default=lambda o: getattr(o, 'as_dict', str)(), indent=2)
|