Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more flexibility in configuration filepath destination? #152

Open
ardumont opened this issue Mar 3, 2019 · 1 comment
Open

Allow more flexibility in configuration filepath destination? #152

ardumont opened this issue Mar 3, 2019 · 1 comment

Comments

@ardumont
Copy link

ardumont commented Mar 3, 2019

Hello,

First, thanks for tvnamer, quite a time saver!

Regarding moving file configuration, this would be great to allow more
flexibility in the path setup (move_files_destination option).

For example, today we can define:

...
"move_files_destination": ".../tvshow/%(seriesname)s/%(seasonnumber)d/",
...

I'd like to be able to set a more specific path still based on those
options, for example, splitting on the first letter of the tvshow:

...
"move_files_destination": ".../tvshow/%(seriesname[0])/s%(seriesname)s/%(seasonnumber)d/",
...

As far as i could see in the code, that part is static so we cannot
yet (checked doc, code and issues). The formatting uses a dict with
special keywords [1].

[1]

tvnamer/tvnamer/main.py

Lines 63 to 74 in d4f5262

destdir = Config['move_files_destination'] % {
'seriesname': wrap_validfname(episode.seriesname),
'episodenumbers': wrap_validfname(formatEpisodeNumbers(episode.episodenumbers)),
'originalfilename': episode.originalfilename,
}
else:
destdir = Config['move_files_destination'] % {
'seriesname': wrap_validfname(episode.seriesname),
'seasonnumber': episode.seasonnumber,
'episodenumbers': wrap_validfname(formatEpisodeNumbers(episode.episodenumbers)),
'originalfilename': episode.originalfilename,
}

To test the idea, i patched locally my installation to adapt that dict
accordingly (for all conditionals), for example:

 isinstance(episode, NoSeasonEpisodeInfo):
        seriesname = wrap_validfname(episode.seriesname)
        destdir = Config['move_files_destination'] % {
            'seriesname[0]': seriesname[0],
            'seriesname': seriesname,
	    ...

I found this rather limited but it works.

I don't really know how to apply this generically though (maybe some
users would want that on other keys and with more than 1 first
letter).


config:

  • Raspbian GNU/Linux 9.8 (stretch)
  • Python 3.5.3 (default, Sep 27 2018, 17:25:39)
  • tvnamer.version (2, 5)


Relatedly, other tools like flexget [2] uses jinja [3]. That allows
configuration to look like:

{{ tvdb_series_name | lower | first }}

(this is verbose but it's declarative enough ;)

Then again that adds a new dependency and possibly new issues for you
later down the line.

[2] https://github.com/Flexget/Flexget

[3] http://jinja.pocoo.org/

Cheers,

@ardumont
Copy link
Author

I found this rather limited but it works.

I don't really know how to apply this generically though (maybe some
users would want that on other keys and with more than 1 first
letter).

In the mean time, here is my actual proposal [1]

I have been using this successfully for a while now [2]

[1] ardumont@d301257

[2] https://gitlab.com/ardumont/nixos/-/blob/master/rpi4/pytools/default.nix#L31

Cheers,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants