cochize1 44 Posted September 4 Posted September 4 So, after some trial and errors with a little (huge actually) help of chat gpt I managed to write a script that basically updates IMDB rating for Movies and Series. I also asked it to summarize the steps we took to help others and recreate them. So far, I managed to update my whole library without any major errors but please test it on some sample one first. Some footnotes: Script runs through the nfo files within your folders looking for <ratings> marking and if necessary update it via OMDB api. When that results in N/A (especially newly released movies or series) it falls back to using IMDBPy library (that should work on itself but is significantly slower then using an OMDB api) Main distinction between TV Shows and Movies is: <imdbid> is used for movies and <imdb_id> is used for Series in tvshow.nfo file. Yet again <imdbid> is also used for every single episode’s IMDB rating so this is will result if you run the script for a Mixed Content library. Of course you can run movie.py script for TV Shows library but it will take much longer as it will be scrapping ratings for each individual episode at a time. As I said, it is possible to adjust the script to only use IMDBPy library but I highly recommend signing up for free OMDB api key (up to 1000 requests per day) or as I did, sign for 2 USD/month Patreon OMDB api key with 100 000 requests limit per day. I suggest turning of real time monitoring of the library as it my fall in loop (probably not endless but still, I had to restart the server several times). Just scan the library after you’re done. There were some back and forth changes to why the script looks as such but I won’t be going into the details for that. Here is the summarized steps we’ve taken to get to this point: Steps Taken: Initial Concept: We started by discussing a script that could update IMDb ratings in .nfo files for TV shows and movies. Original Script for TV Shows: You provided a script that updated IMDb ratings in tvshow.nfo files using the OMDB API. We added error handling and fallbacks using the IMDbPy library if the OMDB API didn't return a rating. Adaptation for Movies: We adapted the TV show script to work with movies. This involved adjusting the script to handle movie-specific .nfo files. Logging Implementation: We implemented logging to track the script's progress and capture any errors or warnings. Logs are written both to a file (movie_update_log.txt) and to the console. Summary Output: We added a summary at the end of the script to report the total number of movies updated or unchanged. This summary is printed to the console and saved to a text file (movies_update_summary.txt). Final Code: The final code combines all these elements: rating retrieval (via OMDB and IMDbPy), .nfo file updating, error handling, logging, and summary generation. Required Installations: To run the script, you'll need to install a few Python libraries. Here’s what needs to be installed: IMDbPy - This library allows you to fetch movie data from IMDb, including ratings. Installation: pip install IMDbPY Requests - A simple HTTP library for Python, used to make requests to the OMDB API. Installation: pip install requests How to Use the Script: Get Your OMDB API Key: Sign up for a free API key at OMDB API. Replace the placeholder '8d213e48' in the script with your actual OMDB API key. (this one is fake obviously) Update the Folder Path: Change the movie_folder path in the script to point to the directory containing your movie .nfo files. Run the Script: Execute the script using Python. It will update the IMDb ratings in your .nfo files, log the process, and generate a summary python movie.py By no means I am a programmer and understand how all this works so feel free to modify and adjust that to your needs. I am glad I don't have to check for movies or series on IMDB manually because the rating has changed. It would be great if there was an additional option except for refreshing metadata but there is none so far. I would really like to think what you guys think of it: @Luke @Happy2Play @Carlo @chef movie.py tv.py 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now