From 86d17c5e22a41a44a24df0107d9677070e343054 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Wed, 17 Oct 2018 22:51:56 +0200 Subject: [PATCH] Recatored the cli program. --- requirements.txt | 1 + src/cli.py | 52 ++++++++++++------------------------------------ 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/requirements.txt b/requirements.txt index 01e0530..0a9c345 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ hashids==1.2.0 enzyme>=0.4.1 click>=6.7 langdetect>=1.0.7 +titlecase>=0.12.0 diff --git a/src/cli.py b/src/cli.py index 05c817e..9060dfe 100755 --- a/src/cli.py +++ b/src/cli.py @@ -1,43 +1,17 @@ -#/usr/local/bin/python3 -import click -import os -import logging +#!usr/bin/env python3.6 -import env_variables as env +from core import scan_folder, moveHome +from video import Video +from guessit import guessit -logging.basicConfig(filename=env.logfile, level=logging.INFO) -logger = logging.getLogger('seasonedParser') -fh = logging.FileHandler(env.logfile) -fh.setLevel(logging.INFO) +videos, insufficient_info = scan_folder('Spider.Man') +print('Sweet lemonade: {} {}'.format(videos, insufficient_info)) -formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') -fh.setFormatter(formatter) +for video in videos: + moveHome(video) -logger.addHandler(fh) - -def listPath(path): - if (os.path.isdir(path)): - print('Contents of path:') - print(os.listdir(path)) - - elif os.path.isfile(path): - print('File to parse:') - print(path) - - else: - print('Path does not exists') - -def guessFromInput(video): - print('Insufficient info for {}'.format(video.name)) - video_name = input('Input - -@click.command() -@click.argument('path') -@click.option('--greeting', '-g') -def main(path, greeting): - logger.info('Received cli variables: \n\t path: {}'.format(path)) - listPath(path) - - -if __name__ == '__main__': - main() +for file in insufficient_info: + supplementary_info = input("Insufficient info for match file: '{}'\nSupplementary info: ".format(file)) + print(supplementary_info) + video = Video.fromguess(file, guessit(supplementary_info)) + moveHome(video)