This commit is contained in:
Gregory Salaun 2021-12-08 13:14:40 +01:00
parent 296a667564
commit 9600a99bf7
2 changed files with 15 additions and 10 deletions

View File

@ -1,7 +1,7 @@
class MovieCollection: class MovieCollection:
def __init__(self, id, title): def __init__(self):
self.collectionTitle = title self.collectionTitle = ""
self.collectionId = id self.collectionId = ""
def get_existing_collections(self): def get_existing_collections(self):
pass pass

View File

@ -28,23 +28,24 @@ MovieCollectionFinal = []
print(":: CollectionUpdater :: Creating Empty lists") print(":: CollectionUpdater :: Creating Empty lists")
# Retrieve the library Movies from Plex # Retrieve the library Movies from Plex
print(f":: {dt.now()} :: CollectionUpdater :: Retrieving Movies section from Plex") print(f":: {dt.now().strftime('%d-%m-%Y %H:%M:%S')} :: CollectionUpdater :: Retrieving Movies section from Plex")
plexMoviesLibrary = plex.library.section('Movies') plexMoviesLibrary = plex.library.section('Movies')
print(f":: {dt.now()} :: CollectionUpdater :: Movies section from Plex retrieved") print(f":: {dt.now().strftime('%d-%m-%Y %H:%M:%S')} :: CollectionUpdater :: Movies section from Plex retrieved")
print(f":: {dt.now()} :: CollectionUpdater :: Creating Movies list and Collection Available in Plex") print(f":: {dt.now().strftime('%d-%m-%Y %H:%M:%S')} :: CollectionUpdater :: Creating Movies list and Collection Available in Plex")
for movie in plexMoviesLibrary.search(): for movie in plexMoviesLibrary.search():
for collection in movie.collections: for collection in movie.collections:
if collection.tag and collection.tag not in AvailablePlexCollectionsMovies: if collection.tag and collection.tag not in AvailablePlexCollectionsMovies:
AvailablePlexCollectionsMovies.append(collection.tag) AvailablePlexCollectionsMovies.append(collection.tag)
print(f":: {dt.now().strftime('%d-%m-%Y %H:%M:%S')} :: CollectionUpdater :: Adding {movie.title} in the list of movies Available in Plex")
PlexMovieList.append(movie.title) PlexMovieList.append(movie.title)
print(f":: {dt.now()} :: CollectionUpdater :: Lists created") print(f":: {dt.now().strftime('%d-%m-%Y %H:%M:%S')} :: CollectionUpdater :: Lists created")
i = 0 i = 0
length = len(PlexMovieList) length = len(PlexMovieList)
print(f":: {dt.now()} :: CollectionUpdater :: Comparing Movies in Plex to find similar movies...") print(f":: {dt.now().strftime('%d-%m-%Y %H:%M:%S')} :: CollectionUpdater :: Comparing Movies in Plex to find similar movies...")
while i < length: while i < length:
for movie in PlexMovieList: for movie in PlexMovieList:
if 85 < fuzz.ratio(PlexMovieList[i], movie) < 100: if 85 < fuzz.ratio(PlexMovieList[i], movie) < 100:
@ -52,8 +53,9 @@ while i < length:
MatchingList.append(PlexMovieList[i]) MatchingList.append(PlexMovieList[i])
i += 1 i += 1
print(f":: {dt.now()} :: CollectionUpdater :: Comparison is finished...") print(f":: {dt.now().strftime('%d-%m-%Y %H:%M:%S')} :: CollectionUpdater :: Comparison is finished...")
print(f":: {dt.now().strftime('%d-%m-%Y %H:%M:%S')} :: CollectionUpdater :: Searching TMDb for movies in the Matching List")
for movie in MatchingList: for movie in MatchingList:
movieSearch = tmdbMovie.search(movie) movieSearch = tmdbMovie.search(movie)
movieId = movieSearch[0].id movieId = movieSearch[0].id
@ -69,5 +71,8 @@ for id in TMDbCollection:
MovieCollectionFinal.append(tmdbCollection.details(id)) MovieCollectionFinal.append(tmdbCollection.details(id))
for movie in MovieCollectionFinal: for movie in MovieCollectionFinal:
coll = MovieCollection()
nameLength = len(movie) nameLength = len(movie)
print(movie.name[:nameLength - 13]) coll.collectionTitle = movie.name[:nameLength - 13]
coll.collectionId = movie.id
print(f"Collection {coll.collectionTitle} with Id: {coll.collectionId} has been added")