Compare commits
3 Commits
ac89cbf545
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16000bc576 | ||
|
|
edd918cb5c | ||
|
|
8fed8325ca |
91
SeFree-Custom-Script/remove_track.py
Normal file
91
SeFree-Custom-Script/remove_track.py
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
import subprocess
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
INPUT_DIR = Path("/Entertainment_1/Downloads/USCK/Series/Hokkaido.Gals.Are.Super.Adorable.2024.S01.1080p.CR.WEB-DL.DUAL.AAC2.0.H.264-[SeFree]")
|
||||||
|
OUTPUT_DIR = INPUT_DIR / "output"
|
||||||
|
|
||||||
|
# remove only forced thai
|
||||||
|
TARGET_LANGS = ["tha"]
|
||||||
|
REMOVE_FORCED = True
|
||||||
|
|
||||||
|
# track types to apply
|
||||||
|
TRACK_TYPES = ["subtitles"]
|
||||||
|
|
||||||
|
OUTPUT_DIR.mkdir(exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
def get_tracks(file):
|
||||||
|
cmd = ["mkvmerge", "-J", str(file)]
|
||||||
|
result = subprocess.run(cmd, capture_output=True, text=True)
|
||||||
|
return json.loads(result.stdout)["tracks"]
|
||||||
|
|
||||||
|
|
||||||
|
def split_tracks(tracks):
|
||||||
|
keep = {
|
||||||
|
"video": [],
|
||||||
|
"audio": [],
|
||||||
|
"subtitles": [],
|
||||||
|
}
|
||||||
|
|
||||||
|
removed = []
|
||||||
|
|
||||||
|
for t in tracks:
|
||||||
|
track_id = t["id"]
|
||||||
|
track_type = t["type"]
|
||||||
|
props = t["properties"]
|
||||||
|
|
||||||
|
lang = props.get("language")
|
||||||
|
forced = props.get("forced_track", False)
|
||||||
|
|
||||||
|
should_remove = False
|
||||||
|
|
||||||
|
# remove ONLY forced thai subtitles
|
||||||
|
if (
|
||||||
|
track_type in TRACK_TYPES
|
||||||
|
and TARGET_LANGS
|
||||||
|
and lang in TARGET_LANGS
|
||||||
|
and REMOVE_FORCED
|
||||||
|
and forced
|
||||||
|
):
|
||||||
|
should_remove = True
|
||||||
|
|
||||||
|
if should_remove:
|
||||||
|
removed.append(track_id)
|
||||||
|
else:
|
||||||
|
if track_type in keep:
|
||||||
|
keep[track_type].append(track_id)
|
||||||
|
|
||||||
|
return keep, removed
|
||||||
|
|
||||||
|
|
||||||
|
for mkv_file in INPUT_DIR.glob("*.mkv"):
|
||||||
|
print(f"Processing: {mkv_file.name}")
|
||||||
|
|
||||||
|
tracks = get_tracks(mkv_file)
|
||||||
|
keep, removed = split_tracks(tracks)
|
||||||
|
|
||||||
|
if not removed:
|
||||||
|
print(" No forced Thai tracks")
|
||||||
|
continue
|
||||||
|
|
||||||
|
output_file = OUTPUT_DIR / mkv_file.name
|
||||||
|
|
||||||
|
cmd = ["mkvmerge", "-o", str(output_file)]
|
||||||
|
|
||||||
|
if keep["video"]:
|
||||||
|
cmd.extend(["--video-tracks", ",".join(map(str, keep["video"]))])
|
||||||
|
|
||||||
|
if keep["audio"]:
|
||||||
|
cmd.extend(["--audio-tracks", ",".join(map(str, keep["audio"]))])
|
||||||
|
|
||||||
|
if keep["subtitles"]:
|
||||||
|
cmd.extend(["--subtitle-tracks", ",".join(map(str, keep["subtitles"]))])
|
||||||
|
|
||||||
|
cmd.append(str(mkv_file))
|
||||||
|
|
||||||
|
subprocess.run(cmd)
|
||||||
|
|
||||||
|
print(f" Removed forced Thai tracks: {removed}")
|
||||||
|
|
||||||
|
print("Done")
|
||||||
Submodule Unshackle-Service-SeFree updated: d6083f21b7...d464d0fac8
@@ -355,7 +355,7 @@ async def process_download(entry):
|
|||||||
# cmd += ['--delay', '10']
|
# cmd += ['--delay', '10']
|
||||||
|
|
||||||
if entry['no_cache'] or entry['service'] in ['HMAX'] :
|
if entry['no_cache'] or entry['service'] in ['HMAX'] :
|
||||||
cmd.append('--no-cache')
|
cmd.append('--cdm-only')
|
||||||
|
|
||||||
if entry['quality'].lower() != 'best':
|
if entry['quality'].lower() != 'best':
|
||||||
cmd += ['--quality', entry['quality']]
|
cmd += ['--quality', entry['quality']]
|
||||||
|
|||||||
Reference in New Issue
Block a user