dbr / tvnamer

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

Only first Episode gets renamed #205

Closed markus681 closed 2 years ago

markus681 commented 2 years ago

Hello,

I'am running tvnamer's last Version 3.0.4 on my Ubuntu 20.04.3 LTS Server on a headless machine, Python Version is "Python 3.8.10". I also have a TvDB API Key, that is in the config file.

My problem is that i only get the first Episode renamed from 8 that are available on "thetvdb.com". I don't know why this happens...hopefully you can help....

I also created a new config file from tvnamer and edited to my needs and add the API Key... here's my config file

{
  "always_move": false,
  "always_rename": false,
  "batch": false,
  "custom_filename_character_blacklist": "",
  "dry_run": false,
  "episode_separator": "-",
  "episode_single": "%02d",
  "extension_pattern": "(\\.[a-zA-Z0-9]+)$",
  "filename_anime_with_episode": "[%(group)s] %(seriesname)s - %(episode)s - %(episodename)s [%(crc)s]%(ext)s",
  "filename_anime_with_episode_without_crc": "[%(group)s] %(seriesname)s - %(episode)s - %(episodename)s%(ext)s",
  "filename_anime_without_episode": "[%(group)s] %(seriesname)s - %(episode)s [%(crc)s]%(ext)s",
  "filename_anime_without_episode_without_crc": "[%(group)s] %(seriesname)s - %(episode)s%(ext)s",
  "filename_blacklist": [],
  "filename_patterns": [
    "^\\[(?P<group>.+?)\\][ ]?               # group name, captured for [#100]\n        (?P<seriesname>.*?)[ ]?[-_][ ]?          # show name, padding, spaces?\n        (?P<episodenumberstart>\\d+)              # first episode number\n        ([-_]\\d+)*                               # optional repeating episodes\n        [-_](?P<episodenumberend>\\d+)            # last episode number\n        (?=                                      # Optional group for crc value (non-capturing)\n          .*                                     # padding\n          \\[(?P<crc>.+?)\\]                       # CRC value\n        )?                                       # End optional crc group\n        [^\\/]*$",
    "^\\[(?P<group>.+?)\\][ ]?               # group name, captured for [#100]\n        (?P<seriesname>.*)                       # show name\n        [ ]?[-_][ ]?                             # padding and seperator\n        (?P<episodenumber>\\d+)                   # episode number\n        (?=                                      # Optional group for crc value (non-capturing)\n          .*                                     # padding\n          \\[(?P<crc>.+?)\\]                       # CRC value\n        )?                                       # End optional crc group\n        [^\\/]*$",
    "\n        ^((?P<seriesname>.+?)[ \\._\\-])?          # show name\n        [Ss](?P<seasonnumber>[0-9]+)             # s01\n        [\\.\\- ]?                                 # separator\n        [Ee](?P<episodenumberstart>[0-9]+)       # first e23\n        ([\\.\\- ]+                                # separator\n        [Ss](?P=seasonnumber)                    # s01\n        [\\.\\- ]?                                 # separator\n        [Ee][0-9]+)*                             # e24 etc (middle groups)\n        ([\\.\\- ]+                                # separator\n        [Ss](?P=seasonnumber)                    # last s01\n        [\\.\\- ]?                                 # separator\n        [Ee](?P<episodenumberend>[0-9]+))        # final episode number\n        [^\\/]*$",
    "\n        ^((?P<seriesname>.+?)[ \\._\\-])?          # show name\n        [Ss](?P<seasonnumber>[0-9]+)             # s01\n        [\\.\\- ]?                                 # separator\n        [Ee](?P<episodenumberstart>[0-9]+)       # first e23\n        ([\\.\\- ]?                                # separator\n        [Ee][0-9]+)*                             # e24e25 etc\n        [\\.\\- ]?[Ee](?P<episodenumberend>[0-9]+) # final episode num\n        [^\\/]*$",
    "\n        ^((?P<seriesname>.+?)[ \\._\\-])?          # show name\n        (?P<seasonnumber>[0-9]+)                 # first season number (1)\n        [xX](?P<episodenumberstart>[0-9]+)       # first episode (x23)\n        ([ \\._\\-]+                               # separator\n        (?P=seasonnumber)                        # more season numbers (1)\n        [xX][0-9]+)*                             # more episode numbers (x24)\n        ([ \\._\\-]+                               # separator\n        (?P=seasonnumber)                        # last season number (1)\n        [xX](?P<episodenumberend>[0-9]+))        # last episode number (x25)\n        [^\\/]*$",
    "\n        ^((?P<seriesname>.+?)[ \\._\\-])?          # show name\n        (?P<seasonnumber>[0-9]+)                 # 1\n        [xX](?P<episodenumberstart>[0-9]+)       # first x23\n        ([xX][0-9]+)*                            # x24x25 etc\n        [xX](?P<episodenumberend>[0-9]+)         # final episode num\n        [^\\/]*$",
    "\n        ^((?P<seriesname>.+?)[ \\._\\-])?          # show name\n        [Ss](?P<seasonnumber>[0-9]+)             # s01\n        [\\.\\- ]?                                 # separator\n        [Ee](?P<episodenumberstart>[0-9]+)       # first e23\n        (                                        # -24 etc\n             [\\-]\n             [Ee]?[0-9]+\n        )*\n             [\\-]                                # separator\n             [Ee]?(?P<episodenumberend>[0-9]+)   # final episode num\n        [\\.\\- ]                                  # must have a separator (prevents s01e01-720p from being 720 episodes)\n        [^\\/]*$",
    "\n        ^((?P<seriesname>.+?)[ \\._\\-])?          # show name\n        (?P<seasonnumber>[0-9]+)                 # 1\n        [xX](?P<episodenumberstart>[0-9]+)       # first x23\n        (                                        # -24 etc\n             [\\-+][0-9]+\n        )*\n             [\\-+]                               # separator\n             (?P<episodenumberend>[0-9]+)        # final episode num\n        ([\\.\\-+ ].*                              # must have a separator (prevents 1x01-720p from being 720 episodes)\n        |\n        $)",
    "^(?P<seriesname>.+?)[ \\._\\-]          # show name and padding\n        \\[                                       # [\n            ?(?P<seasonnumber>[0-9]+)            # season\n        [xX]                                     # x\n            (?P<episodenumberstart>[0-9]+)       # episode\n            ([\\-+] [0-9]+)*\n        [\\-+]                                    # -\n            (?P<episodenumberend>[0-9]+)         # episode\n        \\]                                       # \\]\n        [^\\\\/]*$",
    "^((?P<seriesname>.+?)[ \\._\\-])?       # show name and padding\n        \\[                                       # [ not optional (or too ambigious)\n        (?P<episodenumber>[0-9]+)                # episode\n        \\]                                       # ]\n        [^\\\\/]*$",
    "^(?P<seriesname>.+?)[ \\._\\-]\n        [Ss](?P<seasonnumber>[0-9]{2})\n        [\\.\\- ]?\n        (?P<episodenumber>[0-9]{2})\n        [^0-9]*$",
    "^((?P<seriesname>.+?)[ \\._\\-])?       # show name and padding\n        \\[?                                      # [ optional\n        (?P<seasonnumber>[0-9]+)                 # season\n        [xX]                                     # x\n        (?P<episodenumber>[0-9]+)                # episode\n        \\]?                                      # ] optional\n        [^\\\\/]*$",
    "^((?P<seriesname>.+?)[ \\._\\-])?\n        \\[?\n        [Ss](?P<seasonnumber>[0-9]+)[ ]?[\\._\\- ]?[ ]?\n        [Ee]?(?P<episodenumber>[0-9]+)\n        \\]?\n        [^\\\\/]*$",
    "\n        ^((?P<seriesname>.+?)[ \\._\\-])?          # show name\n        (?P<year>\\d{4})                          # year\n        [ \\._\\-]                                 # separator\n        (?P<month>\\d{2})                         # month\n        [ \\._\\-]                                 # separator\n        (?P<day>\\d{2})                           # day\n        [^\\/]*$",
    "^((?P<seriesname>.+?))                # show name\n        [ \\._\\-]?                                # padding\n        \\[                                       # [\n        (?P<seasonnumber>[0-9]+?)                # season\n        [.]                                      # .\n        (?P<episodenumber>[0-9]+?)               # episode\n        \\]                                       # ]\n        [ \\._\\-]?                                # padding\n        [^\\\\/]*$",
    "^(?P<seriesname>.+?)[ ]?[ \\._\\-][ ]?\n        [Ss](?P<seasonnumber>[0-9]+)[\\.\\- ]?\n        [Ee]?[ ]?(?P<episodenumber>[0-9]+)\n        [^\\\\/]*$",
    "\n        (?P<seriesname>.+)                       # Showname\n        [ ]-[ ]                                  # -\n        [Ee]pisode[ ]\\d+                         # Episode 1234 (ignored)\n        [ ]\n        \\[                                       # [\n        [sS][ ]?(?P<seasonnumber>\\d+)            # s 12\n        ([ ]|[ ]-[ ]|-)                          # space, or -\n        ([eE]|[eE]p)[ ]?(?P<episodenumber>\\d+)   # e or ep 12\n        \\]                                       # ]\n        .*$                                      # rest of file\n        ",
    "^(?P<seriesname>.+?)                  # Show name\n        [ \\._\\-]                                 # Padding\n        (?P<episodenumber>[0-9]+)                # 2\n        of                                       # of\n        [ \\._\\-]?                                # Padding\n        \\d+                                      # 6\n        ([\\._ -]|$|[^\\\\/]*$)                     # More padding, then anything\n        ",
    "(?i)^\n        (?P<seriesname>.+?)                        # Show name\n        [ \\._\\-]                                   # Padding\n        (?:part|pt)?[\\._ -]\n        (?P<episodenumberstart>[0-9]+)             # Part 1\n        (?:\n          [ \\._-](?:and|&|to)                        # and\n          [ \\._-](?:part|pt)?                        # Part 2\n          [ \\._-](?:[0-9]+))*                        # (middle group, optional, repeating)\n        [ \\._-](?:and|&|to)                        # and\n        [ \\._-]?(?:part|pt)?                       # Part 3\n        [ \\._-](?P<episodenumberend>[0-9]+)        # last episode number, save it\n        [\\._ -][^\\\\/]*$                            # More padding, then anything\n        ",
    "^(?P<seriesname>.+?)                  # Show name\\n\n        [ \\\\._\\\\-]                               # Padding\\n\n        [Pp]art[ ](?P<episodenumber>[0-9]+)      # Part 1\\n\n        [\\\\._ -][^\\\\/]*$                         # More padding, then anything\\n\n        ",
    "^(?P<seriesname>.+?)[ ]?               # Show name\n        [Ss]eason[ ]?(?P<seasonnumber>[0-9]+)[ ]? # Season 1\n        [Ee]pisode[ ]?(?P<episodenumber>[0-9]+)   # Episode 20\n        [^\\\\/]*$",
    "^(?P<seriesname>.+)[ \\._\\-]\n        (?P<seasonnumber>[0-9]{1})\n        (?P<episodenumber>[0-9]{2})\n        [\\._ -][^\\\\/]*$",
    "^(?P<seriesname>.+)[ \\._\\-]\n        (?P<seasonnumber>[0-9]{2})\n        (?P<episodenumber>[0-9]{2,3})\n        [\\._ -][^\\\\/]*$",
    "^(?P<seriesname>.+?)                  # Show name\n        [ \\._\\-]                                 # Padding\n        [Ee](?P<episodenumber>[0-9]+)            # E123\n        [\\._ -][^\\\\/]*$                          # More padding, then anything\n        "
  ],
  "filename_with_date_and_episode": "%(seriesname)s - E%(episode)s - %(episodename)s%(ext)s",
  "filename_with_date_without_episode": "%(seriesname)s - E%(episode)s%(ext)s",
  "filename_with_episode": "%(seriesname)s - S%(seasonnumber)02dE%(episode)s - %(episodename)s%(ext)s",
  "filename_with_episode_no_season": "%(seriesname)s - E%(episode)s - %(episodename)s%(ext)s",
  "filename_without_episode": "%(seriesname)s - S%(seasonnumber)02dE%(episode)s%(ext)s",
  "filename_without_episode_no_season": "%(seriesname)s - E%(episode)s%(ext)s",
  "force_name": null,
  "input_filename_replacements": [],
  "input_series_replacements": {},
  "language": "en",
  "leave_symlink": false,
  "lowercase_filename": false,
  "move_files_confirmation": true,
  "move_files_destination": ".",
  "move_files_destination_date": ".",
  "move_files_destination_is_filepath": false,
  "move_files_enable": false,
  "move_files_fullpath_replacements": [],
  "move_files_lowercase_destination": false,
  "move_files_only": false,
  "multiep_format": "%(epname)s (%(episodemin)s-%(episodemax)s)",
  "multiep_join_name_with": ", ",
  "normalize_unicode_filenames": false,
  "order": "aired",
  "output_filename_replacements": [],
  "output_series_replacements": {},
  "overwrite_destination_on_move": false,
  "overwrite_destination_on_rename": false,
  "recursive": false,
  "replace_invalid_characters_with": "",
  "search_all_languages": true,
  "select_first": false,
  "series_id": null,
  "show_version": null,
  "skip_behaviour": "skip",
  "skip_file_on_error": true,
  "titlecase_filename": false,
  "tvdb_api_key": "API-KEY",
  "valid_extensions": [],
  "verbose": false,
  "windows_safe_filenames": true
}

for the command i created a bash file for simple rename

#!/bin/bash

python3 -m tvnamer -c /media/disk2/backup/mytvnamerconfig.json --series-id="$1" "$2"

that's the Series i tried to rename the filenames are "archive.81.s01e02.german.dl.720p.web.x264-***.mkv"

markus@bigeddy /m/d/S/A/Archive 81 S01> tvnamer 390936 *
Loading config: /media/disk2/backup/mytvnamerconfig.json
####################
# Starting tvnamer
# Found 1 episode
####################
# Processing file: Archive 81 - S01E01 - Mystery Signals.mkv
# Detected series: Archive 81 (season: 1, episode: 1)
####################
Existing filename is correct: Archive 81 - S01E01 - Mystery Signals.mkv
####################

####################
# Done

Sorry for my bad English...

Thanks for the Help Guys

Greetz

dbr commented 2 years ago

I think the problem is just with your bash script, where you do "$2"

In your example command, markus@bigeddy /m/d/S/A/Archive 81 S01> tvnamer 390936 * - in the bash script,

..but you are only using $1 and $2

Using something like https://stackoverflow.com/questions/8906187/how-to-skip-the-first-argument-in would be the simplest solution I think, something like

#!/bin/bash

series_id=$1
files="${@:2}" # skip $0 and $1

python3 -m tvnamer -c /media/disk2/backup/mytvnamerconfig.json --series-id=$series_id $files

Hope that helps!