Naming video files/TV shows: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 604: Line 604:
{{top}}
{{top}}


<div style="{{linear-gradient|left|#a1f5e4, #f5f5a1}}">{{next|[[Naming_video_files/Video_File_Tagging|'''Video File Tagging''']]}} </div>
<div style="{{linear-gradient|left|#a1f5e4, #f5f5a1}}">{{next|[[Video_File_Tagging|'''Video File Tagging''']]}} </div>


{{updated|17}}
{{updated|17}}

Revision as of 02:26, 25 January 2018

Create Video Libraries
1. The Basics
2. Source Folder
3. Movie Setup
4a. TV Show Setup
4b. Seasons Setup
4c. Episodes Setup
5. Music Videos Setup
6. Add Source & Scrape
7. Scraping Problems
Home icon grey.png   ▶ Video library ▶ Naming video files ▶ TV shows


Introduction

Setting up TV Shows correctly is a little bit more involved than the Movies section, but not more difficult. This page will describe the Kodi recommended method to name TV Shows and Episode files and to create the folder structure to save them in. These methods are proven to be the simplest, most accurate and robust methods which provide the most accurate scrape.

Any allowable variances to the recommended method will be mentioned (but not displayed in the images) throughout the page.


TheTVDB

The default scraper used by Kodi for TV Shows is the TheTVDB (TVDB). Other scrapers are available and can be found by searching the Kodi site here

See: TheTVDB
See: TheTVDB Add-on


The TVDB scraper has three possible settings for determining episode order: Aired order, DVD order, and Absolute order. These will affect how you name and number your files.


Aired Order
  • TVDB lists all TV shows in the original Aired Order. The first time a show is ever broadcast, that is the listing shown. The site is not concerned with how it was broadcast the 2nd, 3rd or 15th time, or how it was broadcast in other countries, or during syndication. It only lists the order of the FIRST TIME ever broadcast, whether that be on Free To Air or Subscription Television.
  • Episodes are grouped and listed into Seasons and each episode is numbered sequentially from 1, which resets for each season.


DVD Order
  • In many cases, DVD's are released with a different episode listing, normally being the original order envisioned by the Director. To accomodate this, the site also has a DVD Order listing.
  • Episodes are grouped and listed into Seasons and each episode is numbered sequentially from 1, which resets for each season.
  • The first listing (the default listing) displayed by TVDB is Aired Order. If scraping by DVD Order (which is set in the scraper settings), the view listing in TVDB must be changed from Aired Order to DVD Order. At the bottom of the episode list, are the following links. Click on DVD Order, and the screen will refresh with the DVD Order listing.
Previous Season | Next Season | Aired Order | DVD Order
  • There are many TV Shows on the TVDB site that do not have the DVD Order data entered. If this is the case, it is a simple matter to create an account and complete the listing. The scraper will default back to Aired Order if there is no DVD Order information listed.


Absolute Order
  • A third Order option exists. The Absolute Order. This order ignores Seasons and gives each episode an incremental number starting at 1. This order is used for Anime type shows.


To ensure you are using the correct TV Show title follow this simple guideline.

  • The use of the (Year) in the title works differently for TV Shows. In TV Shows, the (Year) is only used when it is shown in the title at the scraper site. See the two images below.
  • This guideline also applies to Country of Origin TV Shows. For example Hells Kitchen (UK), Hells Kitchen (US), Hells Kitchen (AU), Hells Kitchen (IT) etc. What you see on TVDB is how you should name your show.


TV Show Folder

Video-TVShow Folder.png

Each TV Show requires its own folder as the Show Title is extracted from the folder name for a match with with the Information Provider site. For this reason, Kodi cannot support the flat folder structure for TV Shows where all episodes from different TV Shows are in the same folder.

The TV Show folders are located inside the Source folder, explained in the previous page.

The folder name will be cleaned of commonly used strings, such as DVDRip, 1080p, x264, etc. before being passed to the scraper. If the year of release is included, this will be extracted and used by the scraper to assist in making a match.

Spaces, periods, or underscores may be used to separate words in the folder and file names, but shouldn't be mixed in the same folder name. Note also the issue with Split-episodes regarding file names with periods, discussed later.


Recommended

The Kodi Recommended Method is detailed in the image to the right. It has proven to be the simplest, most accurate and reliable method.

The image to the right displays the simplest folder structure and naming convention. The following, commonly used formats, are shown as examples

  • Single File episodes (Angel),
  • DVD folders (Battlestar Galactica)
  • Bluray folders (Battlestar Galactica (2003))



Split folders

Split folders are TV Shows that have episodes split between two or more folders located in different Sources. This may occur when a long running show is progressively saved on one drive but, over time, the drive has been filled with other content, forcing you to save new episodes on another drive.

To ensure these split TV Shows are correctly scraped as the same show, you must ensure that the folder names are identical. A slight variance could see a different show scraped for the second folder.


Other

These other methods are available but NOT recommended. The sub-folders are easily mistaken and scraped as false TV shows. While it is possible to find and fix the ghost entries, the extra time and work involved will override any possible benefits. If you need to re-build your library at a later stage, the problems will need to be solved again.

In more complex situations where your top-level directory is further sub-divided before the show folders, you can add the top-level as source but not set the content, and then set the content to TV shows on each sub-folder.

Example
TV Shows                  <<Source folder, Content: None>>
   |----A-M               <<Content: TV shows>>
   |      |----TV Show 1
   |              |--Files
   |----N-Z               <<Content: TV shows>>
   |      |----TV Show 2
   |              |--Files


It is also possible to have a sub-folder group multiple shows together in an otherwise normal directory structure. Just change the content on the sub-folder and de-select the "Selected folder contains a single TV show" setting.

Example
TV Shows                  <<Source folder, Content: TV shows>>
   |----TV Show 1
   |       |----Season #
   |            |--Files
   |----Star Trek Series  <<Content:TV shows>>
   |       |----Star Trek
   |       |       |--Files
   |       |----Star Trek The Next Generation
   |               |--Files

In these cases, it's best to refrain from scanning the files into the library until the content is set correctly for all folders, to avoid incorrect results and the need to rescan.


Season Folder

Season folders can be added to the TV Show and all episodes sorted into their respective Season folder.

Even though Kodi can accommodate the Season folder, it will ignore them. Instead it looks for the correctly numbered episode files.

As a side note, once your TV Shows have been scanned into the Library, it is possible to rename the Season folder displayed by Kodi. Highlight the Season, call up the Context Menu, select Manage, select Edit Title. An example would be Torchwood and renaming Season 3 to Children of Earth.


Episode Files

All Episode files must be named correctly for the Kodi scraper to match the correct episode at the scraper site.

Kodi uses a series of regular expressions to determine the season and episode numbers from the file name. These are checked in a pre-determined order with the first match being the one used and everything else in the file name is ignored.

There are 8 default patterns, plus a separate multi-episode pattern. Using any other numbering convention will require you to edit your advancedsettings.xml to insert your custom RegEx.

Spaces, periods, or underscores may be used to separate words in the folder and file names, but shouldn't be mixed in the same name. The regex is not case-sensitive and either uppercase or lowercase may be used. The examples on this page use uppercase.

In the examples the following format will be used to demonstrate the naming conventions and regex patterns:

name <<pattern>>.ext

where:

  • name is the title of the show and is optional. It could just as easily be after the pattern, or excluded entirely.
  • <<pattern>> is one of the expressions in the following tables and
  • .ext is a recognized video file extension, (mkv, avi, ts, mp4, etc) or ommitted entirely if using DVD or Bluray folders. (see image above)

Any format will work, so long as the pattern is included somewhere in it.


It is also important to note that Season Numbers may not be basic numbers. Many shows use the Year as the Season number. This is quite common with older shows and also daytime soaps and talk shows. Always check the site


Special Episodes

Special Episdes are episodes that don't fit into the normal storyline of the TV Show. They may include items such as:

  • Christmas Specials,
  • Season recap episodes
  • Made for TV Movies that extend the storyline
  • Unaired Pilots

All Special Episodes use Season 00 eg:

Doctor Who (2005) S00E50

Check the site of the information provider to confirm your files are in the same order. If not, images and metadata will not match your files.


Single Episodes

Most files should contain a single episode. This is the easist and most flexible method.

The following table lists:

  • The pattern that Kodi will search for.
  • The order of the search. ie. Patterns numbered 1 will be matched first and those numbered 7 will be matched last.
With Season
The most common scenario
No Season
In cases where you only have one season (or are using absolute order in the TVDB scraper), you may want to forego the inclusion of the season number.
By date
Common for long-running daily shows, allows the use of aired date of the episode.
With Season No Season By Date
Order Episode Naming Order Episode Naming Order Episode Naming
1 Name S01E02.ext 2 Name ep02.ext 3 Name yyyy.mm.dd.ext
1 Name S1E2.ext 2 Name ep_02.ext 3 Name yyyy-mm-dd.ext
1 Name S01.E02.ext 7 Name part.II.ext 4 Name dd.mm.yyyy.ext
1 Name S01_E02.ext 7 Name pt.II.ext
1 Name S01xE02.ext 7 Name pt_II.ext
5 Name 1x02.ext
6 Name 102.ext




The remainder of this page deals with Special Use cases and can be safely ignored. Most libraries will not require implementing the following additional name extensions.




Multi-Episodes

In cases where the file contains more than one episode, it is possible to specify all the episodes included in that file. Everything after the first found pattern match will be checked for further matches to the same pattern.

When using a single video file for multiple episodes it is possible to tell Kodi when each episode starts using Episode Bookmarks

Two versions are shown- Long version and Short version. Only the episodes in the file name will be added, e.g. name.s01e01-03.ext will not include episode 2.

Using the patterns from the previous section, they have been extended to include multiple episodes. The Order has been ommitted.

See also: multi-episode pattern
Complex Pattern Short Pattern
Order Example Name Order Example Name
name s01e01-s01e02.ext name s01e01e02.ext
name s01e01-episode1.title-s01e02-episode2.title.ext name s01e01-02-03.ext
name s01e01-s01e02-s01e03.ext name 1x01x02.ext
name 1x01-1x02.ext name ep01-02.ext
name ep01-ep02.ext


Split Episodes

Split-episodes are feature length episodes that were broadcast as two separate episodes. The Pilot episode can be a feature length episode for many TV Shows. These are re-combined on DVD releases as the original single episode. They are numbered by decimal sub parts eg S01E01.1, S01E01.2, S01E02 This is a common cause for failed scrapes of certain episodes. The entry must be checked at TVDB to ensure correct numbering has been applied. It is also typical for childrens cartoons, files which only contain a distinct part of an episode may be named as to which part, if the scraper supports it.

Up to 9 sub-parts are allowed (using either .1-.9 or a-i). These can also be combined with the multi-episode pattern, if your file contains all parts joined as a single episode.

Using the patterns from the Single Episodes section, they have been extended to include Split episodes. The Order has been ommitted.

Single Episodes Multi Part Episodes
Order Example Name Order Example Name
name s01e01.1.ext name s01e01.1.s01e01.2.ext
name s01e01a.ext name 1x01.1-x01.2.ext
name 1x01.1.ext name ep01a-01b.ext
name 1x01a.ext
name ep01.1.ext
name 101.1.ext

Each part will be added to the library just with its full episode number, the sub-part will not be displayed.

If you use periods in your file names and include material after the episode number (such as the episode title), you may get a false match to a split-episode pattern if that material begins with a number below 10. This will likely lead to the episode not being added to the library. The recommendation is to use a space or underscore instead to separate the numbers for those files, e.g.


Stub and Stream Files

  • If you have a collection of DVD's and Bluray disks but do not want to rip them to a hard drive, then a Media Stub File allows you to add the collection of disks to the Kodi Video Library.
  • It is a simple text based file that is added to your Source in exactly the same way as any other Movie or TV Show, which is then scanned or scraped into the library.


Various internet video and audio streams can be played back in Kodi as if they were locally stored on your media center by using STRM files. As long as the format and streaming-method (network-protocol) is supported by Kodi, stream can be added. These are basic text files that look like <name>.strm and contain a URL to the internet stream. STRM files can also be added to the video library and can have cover art, summaries, etc.

Some internet sites may have an add-on available that can also access these media streams, rather than having to manually create STRM files. See Add-ons for more information on how to find and install add-ons.


Media Tags / Flags

480.png 1080.png 720.png 1080 n.png 480-1.png Divx.png Xvid.png H264.png Bluray.png Dvd.png Avc1.png 1.33.png 1.66.png 2.20.png 2.35.png


Media flags are icons in Kodi that displays the meta-information from the media file of a movie, TV show or music title. They are skin specific, and what works in one skin, may not work in another skin. It is always best to check with the skin sub-forum which flags and tags are used.

It is important to note that the skin will display these flags even when these extensions are not used. The only difference being that without the extensions, the movie must be played first in order for Kodi to read the audio and video codec data.

The actual audio and video codec data will override any extension used. This means that if you set the extension of, say, .ATMOS but the video file only has a stereo track, then the .ATMOS flag will be removed.


Example- note that movie folders are used, and the folder is simply named while the filename has been modified with extensions.

...\Paul (2011)\Paul (2011).4K.HDR.Atmos.mkv


3D Episodes

Some 3D episodes might need an additional file name extension to be identified by Kodi as 3D. See 3D for details on that additional extension, and when it is needed.


Custom Filenames

It's possible to use custom file names that don't match any of the default patterns by editing your advancedsettings.xml file to include a tvshowmatching tag containing regular expressions.

A tvshowmatching regexp needs up to three capturing groups:

1 capturing group = episode number (season will default to season 1), no multi-episode matches will be attempted
2 capturing groups = season number + episode number (in that order), no multi-episode matches will be attempted
3 capturing groups = season number + episode number + multi-episode matching part (typically just the remainder of the file name)

(A capturing group is essentially a part of the regexp contained inside brackets.)

To have no season but multi-episode matching, use three groups but leave the first empty.

Date-based regexps are also possible, and are marked by a bydate="true" attribute in the regexp. These also use three capturing groups, either as year-month-day or day-month-year, the lengths must be exactly 4-2-2 or 2-2-4.

Your custom tvshowmatching regexps can be either checked for before the default set using action="prepend", or after using action="append". Not including an action will result in only your regexps being tested. Care should be taken to ensure that the right regexp matches your file names, particularly in regard to the three digit "102" pattern seen above. The regexps should be grouped together inside a single tvshowmatching tag, although you can use two if you wish to prepend and append different regexps.

You can also change the multi-episode matching regexp by including a tvmultipartmatching tag in your advancedsettings.xml (separate from the tvshowmatching tag). There can be only one tvmultipartmatching expression, whatever you use will overwrite the default, so take care to only expand on the default pattern unless you are certain. The tvmultipartmatching requires one capturing group for the episode number.

For simplicity, the split-episode pattern has been excluded from the examples below. To allow for split-episodes, replace the [0-9]+ in the episode capturing group with [0-9]+(?:(?:[a-i]|\.[1-9])(?![0-9]))?


Examples

A fairly straightforward example to begin.

Season ## - Episode ##
"Season [season#] - Episode [episode#]" anywhere in the file name
 <tvshowmatching action="prepend">
     <regexp>Season ([0-9]+) - Episode ([0-9]+)([^\\/]*)$</regexp>
 </tvshowmatching>
Example : TV Shows\Scrubs\Season 1\Scrubs - Season 1 - Episode 01 - Pilot.avi
The first two capturing groups should be obvious, the third group ([^\\/]*) captures everything up to the end of the file name $, this allows for multi-part file names such as name.Season 1 - Episode 01 - Season 1 - Episode 02.ext as well as the simpler name.Season 1 - Episode 01-02.ext



The entire file path is passed to the regexps, so care should be taken to ensure the matches can't occur earlier in the path, but this does mean for example, you can capture the season number from a sub-folder name.

\Season #\##
Season [season#] at the end of the directory name, file name starts with [episode#]
 <tvshowmatching action="prepend">
     <regexp>Season[\._ ]([0-9]+)[\\/]([0-9]+)([^\\/]*)$</regexp>
 </tvshowmatching>
Example : \Battlestar Galactica (2003)\Season 3\01 - Occupation.avi (Season 3, Episode 1)
Again we use three groups here to allow for multi-episode, but in this case (obviously) only the shorter multi-episode pattern can occur, e.g. Season 1\01x02 - Episode title.ext.



For numbering without a season, you should ensure that only the episode number gets matched against and not another number in the title or episode title, or a number as part of a different pattern.

- ## -
" - [episode#] - " anywhere in the file name
 <tvshowmatching action="prepend">
     <regexp> - ()([0-9]+)((?:-[0-9]+)*) - [^\\/]*$</regexp>
 </tvshowmatching>
Example : \One Piece\One Piece - 099 - Spirit of the Fakes! Heart of the Rebel Army, Kamyu!.avi ("Season 1", Episode 99) (Using Absolute order)
Here, the first capturing group is left empty, and there is a distinct pattern before and after the episode number to ensure only it gets matched. Also instead of capturing the remainder of the file name for multi-part matching, we only capturing a single repeating pattern so only a - 01-02-03 - format will work.



It's also possible to specify a different default season for without-season regexps.

\Specials\##
Directory name is Specials, file name starts with [episode#]
 <tvshowmatching action="prepend">
     <regexp defaultseason="0">Specials[\\/]()([0-9]+)([^\\/]*)$</regexp>
 </tvshowmatching>
Example : \Firefly\Specials\04 - Browncoats Unite.mkv (Season 0, Episode 4)
A combination of the previous two examples, allowing special episodes to reside in a "Specials" folder rather than a "Season 0" folder.



The default date-based regexps only allow for periods or hyphens as delimiters...

####_##_##
[year]_[month]_[day] anywhere in the file name
 <tvshowmatching action="prepend">
     <regexp bydate="true">([0-9]{4})_([0-9]{2})_([0-9]{2})[^\\/]*$</regexp>
 </tvshowmatching>
Example: : \The Colbert Report\2005_10_17.avi
The exact number of digits is specified for each group to ensure compliance. A separate [month]_[day]_[year] regexp would be needed if both formats are in use.



The default regexps don't allow for DVD folder structures, this can usually be remedied by replacing the final $ with (?:(?:[\\/]video_ts)?[\\/]video_ts\.ifo)$

S##E##\VIDEO_TS\VIDEO_TS.IFO
 <tvshowmatching action="append">
     <regexp>[Ss]([0-9]+)[ ._-]*[Ee]([0-9]+)([^\\/]*)(?:(?:[\\/]VIDEO_TS)?[\\/]VIDEO_TS\.IFO)$</regexp>
 </tvshowmatching>
Example: \Battlestar Galactica (2003)\The Mini-Series S00E01E02\VIDEO_TS\VIDEO_TS.IFO
The VIDEO_TS folder is optional, e.g. S01E01\VIDEO_TS.IFO will also work.



Similarly for Bluray folder structures, you can replace the final $ with (?:(?:[\\/]bdmv)?[\\/]index\.bdmv)$

#x##\BDMV\index.bdmv
 <tvshowmatching action="append">
     <regexp>[\\/\._ \[\(-]([0-9]+)x([0-9]+)([^\\/]*)(?:(?:[\\/]bdmv)?[\\/]index\.bdmv)$</regexp>
 </tvshowmatching>
With Bluray folders, you'll also run into trouble with the various mpls and m2ts files incorrectly matching other patterns, so you should also exclude all the other folders and files from being scanned:
  <video>
    <excludetvshowsfromscan action="append">
      <regexp>[\\/](auxdata|backup|clipinf|playlist|stream|certificate)[\\/]</regexp>
      <regexp>movieobject\.bdmv</regexp>
    </excludetvshowsfromscan>
  </video>



Finally, a tvmultipartmatching example.

S##E##+##
Multiple episode numbers, separated by a + sign
 <tvmultipartmatching>^[-_EeXx+]+([0-9]+)</tvmultipartmatching>
Example: : \Lost\Lost.S01E23+24.Exodus.mkv
In this case we can simply add the + sign to the default symbols, thus preserving the defaults as well.


advancedsettings.xml

The following settings allow user customisation for TV Show and Episode matching.



Return to top


Next step: Video File Tagging