dbr / tvnamer

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

Can't convert Absolute Number to Season+Episode #207

Open AntonyCilleros opened 2 years ago

AntonyCilleros commented 2 years ago

Hello

I have a series (Yu Yu Hakusho) named with absolute number like : "Yu Yu Hakusho - E106 - The Battle of Father and Son.mkv" and I would like to have it like that : "Yu Yu Hakusho - S04E12 - The Battle of Father and Son.mkv"

So my issue is that I can't use %(seasonnumber)02d in filename_with_episode_no_season because it returns me this :

Loading config: settings
####################
# Starting tvnamer
# Found 43 episodes
####################
# Processing file: Yu Yu Hakusho - E001 - Surprised to be Dead.mkv
# Detected series: Yu Yu Hakusho (episode: 1)
Traceback (most recent call last):
  File "/home/raytek/.local/bin/tvnamer", line 8, in <module>
    sys.exit(main())
  File "/home/raytek/.local/lib/python3.8/site-packages/tvnamer/main.py", line 474, in main
    tvnamer(paths = sorted(args))
  File "/home/raytek/.local/lib/python3.8/site-packages/tvnamer/main.py", line 370, in tvnamer
    processFile(tvdb_instance, episode)
  File "/home/raytek/.local/lib/python3.8/site-packages/tvnamer/main.py", line 207, in processFile
    newName = episode.generateFilename()
  File "/home/raytek/.local/lib/python3.8/site-packages/tvnamer/utils.py", line 770, in generateFilename
    fname = Config[self.CFG_KEY_WITH_EP] % epdata
KeyError: 'seasonnumber'

Is there a way to convert an "absolute number" to an "aired order" (Season+Episode) ?

Sorry if I missed something and thanks anyway for this program !

dbr commented 2 years ago

There's not currently a way to do this, as each type of parsed episode only exposes the "relevant" data (e.g the NoSeasonEpisodeInfo class only exposed series name and episode number), for example here:

https://github.com/dbr/tvnamer/blob/2e1e969542d65c5cac2dad9b3cd20dce4f53b6a8/tvnamer/data.py#L528-L533

In retrospect each type should expose all the available data, which isn't a massive change but would probably require some refactoring - however I'm no longer actively developing the tool, so unfortunately it's unlikely to be fixed anytime soon