Merge branch 'master' of github.com:KevinMidboe/seasonMover
This commit is contained in:
		
							
								
								
									
										25
									
								
								src/cli.py
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								src/cli.py
									
									
									
									
									
								
							| @@ -6,18 +6,15 @@ from core import scan_folder, moveHome | |||||||
| from video import Video | from video import Video | ||||||
| from exceptions import InsufficientNameError | from exceptions import InsufficientNameError | ||||||
|  |  | ||||||
| def moveHome(video): |  | ||||||
|     print('Would have moved: {}'.format(video)) |  | ||||||
|  |  | ||||||
| def tweet(video): | def tweet(video): | ||||||
|     pass |     pass | ||||||
|  |  | ||||||
| def prompt(name): | def prompt(name): | ||||||
|     manual_name = input("Insufficient name: '{}'\nInput name manually: ".format(name))  |     manual_name = input("Insufficient name: '{}'\nInput name manually: ".format(name))  | ||||||
|  |  | ||||||
|     if manual_name is 'q': |     if manual_name == 'q': | ||||||
|         assert KeyboardInterrupt |         raise  KeyboardInterrupt | ||||||
|     if manual_name is 's': |     if manual_name == 's': | ||||||
|         return None |         return None | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -25,7 +22,7 @@ def prompt(name): | |||||||
|  |  | ||||||
| @click.command() | @click.command() | ||||||
| @click.argument('path') | @click.argument('path') | ||||||
| @click.option('--daemon', '-d', daemon) | @click.option('--daemon', '-d') | ||||||
| def main(path, daemon): | def main(path, daemon): | ||||||
|     videos, insufficient_name = scan_folder(path) |     videos, insufficient_name = scan_folder(path) | ||||||
|  |  | ||||||
| @@ -33,22 +30,18 @@ def main(path, daemon): | |||||||
|         moveHome(video) |         moveHome(video) | ||||||
|  |  | ||||||
|     while len(insufficient_name) >= 1: |     while len(insufficient_name) >= 1: | ||||||
|         for file in insufficient_name: |         for i, file in enumerate(insufficient_name): | ||||||
|             try: |             try: | ||||||
|                 manual_name = prompt(file) |                 manual_name = prompt(file) | ||||||
|                  |                  | ||||||
|                 if manual_name is None: |                 if manual_name is None: | ||||||
|                     insufficient_name.pop() |                     del insufficient_name[i] | ||||||
|                     continue |                     continue | ||||||
|                  |                  | ||||||
|                 try: |                 video = Video.fromguess(file, guessit(manual_name)) | ||||||
|                     video = Video.fromguess(file, guessit(manual_name)) |                 moveHome(video) | ||||||
|                     moveHome(video) |                 del insufficient_name[i] | ||||||
|                     insufficient_name.pop() |  | ||||||
|  |  | ||||||
|                 except InsufficientNameError: |  | ||||||
|                     continue  |  | ||||||
|                      |  | ||||||
|             except KeyboardInterrupt: |             except KeyboardInterrupt: | ||||||
|                 # Logger: Received interrupt, exiting parser. |                 # Logger: Received interrupt, exiting parser. | ||||||
|                 # should the class objects be deleted ? |                 # should the class objects be deleted ? | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ from video import VIDEO_EXTENSIONS, Episode, Movie, Video | |||||||
| from subtitle import SUBTITLE_EXTENSIONS, Subtitle, get_subtitle_path | from subtitle import SUBTITLE_EXTENSIONS, Subtitle, get_subtitle_path | ||||||
| from utils import sanitize, refine | from utils import sanitize, refine | ||||||
|  |  | ||||||
| logging.basicConfig(filename=env.logfile, level=logging.DEBUG) | logging.basicConfig(filename=env.logfile, level=logging.INFO) | ||||||
| logger = logging.getLogger('seasonedParser') | logger = logging.getLogger('seasonedParser') | ||||||
| fh = logging.FileHandler(env.logfile) | fh = logging.FileHandler(env.logfile) | ||||||
| fh.setLevel(logging.INFO) | fh.setLevel(logging.INFO) | ||||||
| @@ -191,7 +191,7 @@ def scan_videos(path): | |||||||
|                 if filename.endswith(VIDEO_EXTENSIONS):  # video |                 if filename.endswith(VIDEO_EXTENSIONS):  # video | ||||||
|                     try: |                     try: | ||||||
|                         video = scan_video(filepath) |                         video = scan_video(filepath) | ||||||
|                     except InsufficientInfoError as e: |                     except InsufficientNameError as e: | ||||||
|                         logger.info(e) |                         logger.info(e) | ||||||
|                         insufficient_name.append(filepath)                         |                         insufficient_name.append(filepath)                         | ||||||
|                         continue |                         continue | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user