dbr / tvnamer

Automatic TV episode file renamer, uses data from thetvdb.com via tvdb_api
https://pypi.python.org/pypi/tvnamer/
The Unlicense
909 stars 115 forks source link

Take no action on files. Just output episode details to screen in JSON for the user to script whatever they like. #124

Open hi2u opened 8 years ago

hi2u commented 8 years ago

tvnamer has a great engine for parsing filenames and doing the online API query, it would be great to be able to use it just for these two features alone.

Even though there's a ton of options for the actions that tvnamer can take, I've run into a number of limitations for my set up. I would love to just be able to write my own script (in any language that can parse JSON) to perform whatever actions I like. Even stuff other than renaming.

An example of other program that does this is guessit, (however it doesn't do API lookups).

For example, the command:

guessit "The.Daily.Show.2015.08.06.Jon.Stewarts.Final.Episode.540p.WEBRip.AAC2.0.H.264.mkv"

Will output:

{
    "title": "The Daily Show",
    "date": "2015-08-06",
    "episode_title": "Jon Stewarts Final Episode 540p",
    "format": "WEBRip",
    "audio_codec": "AAC",
    "audio_channels": "2.0",
    "video_codec": "h264",
    "container": "mkv",
    "mimetype": "video/x-matroska",
    "type": "episode"
}

tvnamer's code already has all the parsed components (series name/number, episode name/number/date etc) of the filename (before API lookup) -and- also all the returned API records in a bunch of variables anyway, so all that is needed is throwing them into one big fat JSON object and outputting the JSON to the screen. So I would assume this wouldn't be much work?

This would greatly reduce the number of feature requests that users are making, because anybody that can do a bit of their own scripting (in any language) can do it themselves without tvnamer needing their specific functionality. Other people can release their own scripts that make use of tvnamer for various tasks too, and this could in turn encourage more contributors to help add a wider range of functionality to tvnamer such as accessing multiple APIs and working on other types of files like movies and music.

It would also save a lot of re-inventing of the wheel that a lot of other renamers and HTPC programs are doing in regards to filename parsing and API lookups.

If this feature were to be built, it would make sense to also allow tvnamer to be run on filenames that don't actually exist on the filesystem (coming from a script).