Titlecase the homepath and try except creating hash for filename.
This commit is contained in:
17
src/core.py
17
src/core.py
@@ -13,6 +13,7 @@ import logging
|
|||||||
import tvdb_api
|
import tvdb_api
|
||||||
import click
|
import click
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
from titlecase import titlecase
|
||||||
|
|
||||||
import env_variables as env
|
import env_variables as env
|
||||||
|
|
||||||
@@ -72,12 +73,15 @@ def scan_video(path):
|
|||||||
video.size = os.path.getsize(path)
|
video.size = os.path.getsize(path)
|
||||||
|
|
||||||
# hash of name
|
# hash of name
|
||||||
|
try:
|
||||||
if isinstance(video, Movie):
|
if isinstance(video, Movie):
|
||||||
hash_str = ''.join([video.title, str(video.year) or ''])
|
hash_str = ''.join([video.title, str(video.year) or ''])
|
||||||
elif isinstance(video, Episode):
|
elif isinstance(video, Episode):
|
||||||
hash_str = ''.join([video.series, str(video.season), str(video.episode)])
|
hash_str = ''.join([video.series, str(video.season), str(video.episode)])
|
||||||
videoHash = hashlib.md5(hash_str.encode()).hexdigest()
|
videoHash = hashlib.md5(hash_str.encode()).hexdigest()
|
||||||
video.hash = videoHash
|
video.hash = videoHash
|
||||||
|
except:
|
||||||
|
print(video)
|
||||||
|
|
||||||
return video
|
return video
|
||||||
|
|
||||||
@@ -96,7 +100,6 @@ def scan_subtitle(path):
|
|||||||
|
|
||||||
return subtitle
|
return subtitle
|
||||||
|
|
||||||
|
|
||||||
def scan_videos(path):
|
def scan_videos(path):
|
||||||
"""Scan `path` for videos and their subtitles.
|
"""Scan `path` for videos and their subtitles.
|
||||||
|
|
||||||
@@ -118,7 +121,7 @@ def scan_videos(path):
|
|||||||
# setup progress bar
|
# setup progress bar
|
||||||
path_children = 0
|
path_children = 0
|
||||||
for _ in os.walk(path): path_children += 1
|
for _ in os.walk(path): path_children += 1
|
||||||
with click.progressbar(length=path_children, show_pos=True, label='Searching folders for videos') as bar:
|
with click.progressbar(length=path_children, show_pos=True, label='Collecting videos') as bar:
|
||||||
|
|
||||||
# walk the path
|
# walk the path
|
||||||
videos = []
|
videos = []
|
||||||
@@ -270,7 +273,7 @@ def scan_folder(path):
|
|||||||
return videos
|
return videos
|
||||||
|
|
||||||
def movingToCollege(video, home_path):
|
def movingToCollege(video, home_path):
|
||||||
video.home = home_path
|
video.home = titlecase(home_path)
|
||||||
|
|
||||||
def pickforgirlscouts(video):
|
def pickforgirlscouts(video):
|
||||||
if isinstance(video, Movie):
|
if isinstance(video, Movie):
|
||||||
@@ -281,14 +284,14 @@ def pickforgirlscouts(video):
|
|||||||
|
|
||||||
elif isinstance(video, Episode):
|
elif isinstance(video, Episode):
|
||||||
if video.series != None and video.season != None and video.episode != None and type(video.episode) != list:
|
if video.series != None and video.season != None and video.episode != None and type(video.episode) != list:
|
||||||
home_path = '{} S{:02d}E{:02d}'.format(video.series, video.season, video.episode)
|
home_path = '{} S{}E{}'.format(str(video.series), str(video.season), str(video.episode))
|
||||||
movingToCollege(video, home_path)
|
movingToCollege(video, home_path)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
path = '/mnt/rescue/'
|
path = '/mnt/mainframe/'
|
||||||
|
|
||||||
videos = scan_folder(path)
|
videos = scan_folder(path)
|
||||||
|
|
||||||
@@ -310,8 +313,8 @@ def main():
|
|||||||
's' if len(videos) > 1 else ''
|
's' if len(videos) > 1 else ''
|
||||||
))
|
))
|
||||||
|
|
||||||
for video in civilian:
|
for video in scout:
|
||||||
print(video)
|
print('{} lives: {}'.format(video, video.home))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user