view rename.py @ 133:0d8eabdd12ab default tip

create: write H:MM:SS timestamps, add option to fill with gaussian-blur instead of black many albums are longer than one hour so writing H:MM:SS is a necessity. if anything there will just be verbose info that isn't important for my use-case. however the gaussian-blur is simply broken. It works, and it plays locally just fine, but YouTube in particular elongates the video to fit the full width. I'm not entirely sure why it does this, but it makes it useless and ugly.
author Paper <paper@tflc.us>
date Sat, 03 Jan 2026 20:25:38 -0500
parents 2aa9614cb39a
children
line wrap: on
line source

import os
import sys

# valid filename: "[title] - [episode number].mkv"
for file in os.listdir("./"):
    if file.endswith(".mkv"):
        name = file[:-9]

try:
    throwaway = open(f"{name} - 01.mkv", 'rb')
except OSError:
    print(f'Could not open "{name} - 01.mkv". Are you sure the file exists?')
    sys.exit()
throwaway.close()

titles = open('list.txt', 'r', encoding='utf-8')
titlelist = titles.readlines()
titles.close()

count = 1
for line in titlelist:
    line = line.rstrip("\n")
    if int(count) <= 9:
        os.rename(f'{name} - 0{count}.mkv', f'{name} - 0{count} [{line}].mkv')
    else:
        os.rename(f'{name} - {count}.mkv', f'{name} - {count} [{line}].mkv')
    count += 1