Created
February 24, 2018 20:21
-
-
Save feoh/bf27c811bcb5fb6b7174afcb603925e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import pprint | |
import argparse | |
from os.path import join | |
from os import rename | |
from glob import glob | |
def parse_args(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('series', help='TV Series name. e.g. Futuramar') | |
parser.add_argument('directory', help='Directory containing titles to fix.', default='.') | |
parser.add_argument('start', help='Episode number to start on. e.g. 49') | |
parser.add_argument('-s','--season', help='Season these extras are attached to', default='0') | |
return parser.parse_args() | |
def get_files_to_process(args): | |
glob_path = join(args.directory, "title*.mkv") | |
return glob(glob_path) | |
def main(): | |
args = parse_args() | |
pprint.pprint(args) | |
files = get_files_to_process(args) | |
pprint.pprint(files) | |
season = args.season | |
start = int(args.start) | |
for index, file in enumerate(files): | |
episode_number = str(start + index) | |
print("episode_number: {}".format(episode_number)) | |
print("season: {}".format(season)) | |
new_filename = "{}-s{}-e{}.mkv".format(args.series, season.zfill(2), episode_number.zfill(2)) | |
print("new filename: {}".format(new_filename)) | |
# Path needs to be expanded. | |
new_path = join(args.directory + new_filename) | |
print("new pathname: {}".format(new_path)) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment