Jump to content

Script which creates a simple sports NFO file


adamstewiegreen

Recommended Posts

adamstewiegreen

https://github.com/stewiegreen/Sport_NFO

 

I've been slowly learning programming (specifically Python) over the last month and on the weekend I had some time to look up the SportsDB API and write a small script which makes a very (VERY!) basic NFO file for the last game played by specific team and places it in the folder where the script is located.

 

When the script is run it'll ask for the name of the league (NFL, NHL etc) and the name of the team.

 

I'm going to improve it over time, but I'd recommend checking on the SportDB exactly how they name the league and team since some use the common abbreviation (MLB, NHL, NFL, NBA), others only the full name and others are trickier like "St. Louis Blues" (right now) has to have the "." and I saw a couple with dashes and such.

 

In the future I'm hoping to improve the code to:

  • Fetch metadata from any given game on the DB (based on team and date played, most likely).
  • Be less strict when entering a team name/allow team name abbreviations.
  • Give more detailed metadata including an an option to include the score of the game in the NFO.
  • (Later) Have the script automatically parse filenames to completely automating the process.
Edited by adamstewiegreen
Link to comment
Share on other sites

adamstewiegreen

Code wise, it's probably the equivalent of a train wreck but now some of the error handling has been improved, it provides options when the team/league isn't definitive and it'll retrieve info from any game on any date available in the database (not just the latest game).

 

It's still throwing up errors if the date format is entered incorrectly, so I'll work on that next.  Then a more detailed NFO file with an option to add the score to the description.

Link to comment
Share on other sites

adamstewiegreen

Nearly all the error handling has been fixed and a simple way to get the last played game has been added (just leave the date field blank).  There is a section that has been commented out that will include the game's score if it is un-commented (the script is already heavy on user input and I didn't want to add yet another question).

 

Next Goals:

  • Parse filenames so that it does everything based on a filename rather than user input.  The file structure will be something like league_yyyy.mm.dd_awayteam@hometeam.ext (NHL_2019.09.16_Calgary@Vancouver.mkv)
  • Rename file to the same as the .nfo file
  • Have the script do all files in a specific folder(s)
Link to comment
Share on other sites

  • 2 weeks later...
adamstewiegreen

Under the "Experimental" folder I've added the NFO creator files that work within a specified folder (and all subfolders) to attempt to parse files and create relevant game NFOs for those games.  It is accurate if the file names are written as above (with the addition of the station which the game was broadcast on). e.g. NHL_2019.09.16_Calgary@Vancouver_Station.mkv

 

For it to work keep the team names to either their abbreviations, name or city, not both (i.e. Canucks, Vancouver, or Van - not Vancouver Canucks) and add a station (if not present) as I'm still learning how to use regex.

 

I'll keep improving it as I learn.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...