Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: parnexcodes/pyretag
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: avikekk/pyretag
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Nov 11, 2023

  1. Update retag.py

    avikekk authored Nov 11, 2023
    Copy the full SHA
    781fa8e View commit details
  2. Delete binaries directory

    avikekk authored Nov 11, 2023
    Copy the full SHA
    24e6909 View commit details
Showing with 29 additions and 38 deletions.
  1. BIN binaries/mkvmerge.exe
  2. +29 −38 retag.py
Binary file removed binaries/mkvmerge.exe
Binary file not shown.
67 changes: 29 additions & 38 deletions retag.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#!/usr/bin/env python3

import os
import json
import glob
import subprocess
import argparse
import sys
import pyfiglet
from rich import print

print("""[green]
██████╗ ███████╗████████╗ █████╗ ██████╗ ██████╗ ██╗ ██╗
██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██╔════╝ ██╔══██╗╚██╗ ██╔╝
██████╔╝█████╗ ██║ ███████║██║ ███╗ ██████╔╝ ╚████╔╝
██╔══██╗██╔══╝ ██║ ██╔══██║██║ ██║ ██╔═══╝ ╚██╔╝
██║ ██║███████╗ ██║ ██║ ██║╚██████╔╝██╗██║ ██║
╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝╚═╝ ╚═╝
╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝╚═╝ ╚═╝
[/green]""")
print("by [red]parnex[/red]")

@@ -32,13 +31,12 @@
dirPath = os.path.dirname(realPath)
dirName = os.path.basename(dirPath)

input_folder = dirPath + '/input'
output_folder = dirPath + '/output'
delete_folder = dirPath + '\output'
mkvmergeexe = dirPath + '/binaries/mkvmerge.exe'
input_folder = os.path.join(dirPath, 'input')
output_folder = os.path.join(dirPath, 'output')
delete_folder = os.path.join(dirPath, 'output')

with open("config.json") as json_data:
config = json.load(json_data)
config = json.load(json_data)

os.chdir(input_folder)

@@ -53,12 +51,14 @@
list2 = []
for j in list1:
final_file_name = j.replace(input_rls, output_rls)
list2.append(final_file_name)
list2.append(final_file_name)

for k in range(0, len(list2)):
mkv_title = list2[k][0:-4]
print(f'\nSelected file : [yellow]{list1[k]}[/yellow]\n')
subprocess.run(f'{mkvmergeexe} -o {output_folder}/{list2[k]} --title {mkv_title} --track-name 0:"" --track-name 1:"" {list1[k]}', shell=True)
print(f'\nSelected File : [yellow]{list1[k]}[/yellow]\n')
subprocess.run(
f'mkvmerge -o {output_folder}/{list2[k]} --title {mkv_title} --track-name 0:"" --track-name 1:"" {list1[k]}',
shell=True)
print('\nRetagged Successfully!')
print(f'Original : [blue]{list1[k]}[/blue]')
print(f'Retagged : [green]{list2[k]}[/green]\n')
@@ -72,32 +72,23 @@

if config['rclone_upload'] == 'True':
if len(list3) > 1:
os.system(f'mkdir {mkv_title}')
os.system(f'MOVE {output_folder}\* {mkv_title}')
print('\nUploading to cloud.')
subprocess.run(f"rclone copy {output_folder}/ {config['rclone_remote']}: --progress --transfers 20 --drive-chunk-size 32M", shell=True)

print('\nGetting Links.')
os.chdir(dirPath)
links = open('links.txt', 'w')
link_process = subprocess.call(f"rclone link {config['rclone_remote']}:{mkv_title} --retries 15", stdout=links, shell=True)
print('\nLink Saved in links.txt')

destination_dir = os.path.join(output_folder, mkv_title)
if not os.path.exists(destination_dir):
os.mkdir(destination_dir)
os.system(f'mv {output_folder}/* {destination_dir}')
print('\nUploading...')
subprocess.run(
f"gclone copy {destination_dir}/ {config['rclone_remote']}: --progress --transfers 20 --drive-chunk-size 128M",
shell=True)
print('\nUpload Complete')
else:
print(f"Destination Directory '{destination_dir}' Already Exists!")
else:
print('\nUploading to cloud.')
subprocess.run(f"rclone copy {output_folder}/ {config['rclone_remote']}: --progress --transfers 20 --drive-chunk-size 32M", shell=True)

print('\nGetting Links.')
os.chdir(dirPath)
links = open('links.txt', 'w')
link_process = subprocess.call(f"rclone link {config['rclone_remote']}:{list3[0]} --retries 15", stdout=links, shell=True)
print('\nLink Saved in links.txt')

print('\nUploading...')
subprocess.run(
f"gclone copy {output_folder}/ {config['rclone_remote']}: --progress --transfers 20 --drive-chunk-size 128M",
shell=True)
print('\nUpload Complete.')
else:
pass

if config['delete_files'] == 'True':
os.system(f'rmdir /s /q {delete_folder}')
print('\nFiles Deleted Successfully!')
else:
pass