commit 216a001f607009fd5fc859c7e70a842eeb20d291 Author: rouggy Date: Mon Dec 6 15:02:14 2021 +0100 first commit diff --git a/app/plexAutoCollectionUpdater.py b/app/plexAutoCollectionUpdater.py new file mode 100644 index 0000000..107789d --- /dev/null +++ b/app/plexAutoCollectionUpdater.py @@ -0,0 +1,56 @@ +from config.config import Config +from tmdbv3api import TMDb, Movie, Collection +from plexapi.server import PlexServer +from fuzzywuzzy import fuzz + +# Instantiate Tmdb object +tmdb = TMDb() +tmdb.api_key = Config.tmdbApiKey +tmdb.language = Config.tmdbLanguage + +# Instantiate movie object +tmdbMovie = Movie() +tmdbCollection = Collection() + +baseurl = Config.plexBaseUrl +token = Config.plexToken +plex = PlexServer(baseurl, token) + +PlexMovieList = [] +MatchingList = [] +TMDbCollection = [] +MovieCollectionFinal = [] + +movies = plex.library.section('Movies') +for video in movies.search(): + PlexMovieList.append(video.title) + +i = 0 + +length = len(PlexMovieList) + +while i < length: + + for movie in PlexMovieList: + if fuzz.ratio(PlexMovieList[i], movie) > 85 and fuzz.ratio(PlexMovieList[i], movie) < 100: + if PlexMovieList[i] not in MatchingList: + MatchingList.append(PlexMovieList[i]) + + i += 1 + +for movie in MatchingList: + movieSearch = tmdbMovie.search(movie) + movieId = movieSearch[0].id + movieDetails = tmdbMovie.details(movie_id=movieId) + + if movieDetails.belongs_to_collection is not None: + collectionId = movieDetails.belongs_to_collection + + if collectionId.id not in TMDbCollection: + TMDbCollection.append(collectionId.id) + +for id in TMDbCollection: + MovieCollectionFinal.append(tmdbCollection.details(id)) + pass + +print("") \ No newline at end of file diff --git a/config/__init__.py b/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/config/__pycache__/__init__.cpython-39.pyc b/config/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..a26078f Binary files /dev/null and b/config/__pycache__/__init__.cpython-39.pyc differ diff --git a/config/__pycache__/config.cpython-39.pyc b/config/__pycache__/config.cpython-39.pyc new file mode 100644 index 0000000..524a3a5 Binary files /dev/null and b/config/__pycache__/config.cpython-39.pyc differ diff --git a/config/config.py b/config/config.py new file mode 100644 index 0000000..91eeb45 --- /dev/null +++ b/config/config.py @@ -0,0 +1,6 @@ +class Config(object): + tmdbApiKey = '41d05b7a36ba961740f7c05cc4ef634b' + tmdbLanguage = 'fr-FR' + tmdbApiUrl = 'https://api.themoviedb.org/3/search/' + plexBaseUrl = 'https://plex.rouggy.ovh' + plexToken = 'VeQQwtf-sNtWWLwzCEih' diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..51d8750 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +tmdbv3api==1.7.6 +PlexAPI==4.8.0 +fuzzywuzzy==0.18.0 \ No newline at end of file