HOW-TO:Use MakeMKV Template Pattern with TV Shows: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 90: Line 90:
=== Final Results ===
=== Final Results ===
After executing the above shell commands, the directory contents will now be: {{divbox|plain||<code>My Foobar Honey/<br/>My Foobar Honey/Season 1<br/>My Foobar Honey/Season 1/My Foobar Honey (2005) S1E01.mkv<br/>My Foobar Honey/Season 1/My Foobar Honey (2005) S1E02.mkv<br/>My Foobar Honey/Season 1/My Foobar Honey (2005) S1E03.mkv<br/>My Foobar Honey/Season 1/My Foobar Honey (2005) S1E04.mkv<br/>My Foobar Honey/Season 1/My Foobar Honey (2005) S1E05.mkv<br/>My Foobar Honey/Season 1/My Foobar Honey (2005) S1E06.mkv</code>}}
After executing the above shell commands, the directory contents will now be: {{divbox|plain||<code>My Foobar Honey/<br/>My Foobar Honey/Season 1<br/>My Foobar Honey/Season 1/My Foobar Honey (2005) S1E01.mkv<br/>My Foobar Honey/Season 1/My Foobar Honey (2005) S1E02.mkv<br/>My Foobar Honey/Season 1/My Foobar Honey (2005) S1E03.mkv<br/>My Foobar Honey/Season 1/My Foobar Honey (2005) S1E04.mkv<br/>My Foobar Honey/Season 1/My Foobar Honey (2005) S1E05.mkv<br/>My Foobar Honey/Season 1/My Foobar Honey (2005) S1E06.mkv</code>}}
[[Category:How-to]]

Latest revision as of 23:06, 30 January 2022

Do you use MakeMKV for transcoding from different formats (i.e., DVDs, Blu-Rays, etc.) into Matroska Multimedia Container (aka "MKV") formats?

If so, you may have struggled with transcoding a TV show from a DVD into a file that Kodi can properly integrate into your Video Library (category link).

This HOW-TO article provides a step-by-step approach to manage MakeMKV-to-named-for-Kodi TV show episodes.

Overview

When using MakeMKV to transcode a disc that contains multiple TV show episodes, manually renaming things is fairly trivial. What is problematic is when that TV Show has multiple seasons and episodes, the renaming of the various "MKV" files can becoming daunting.

This HOW-TO article provides a general strategy with a specific example done using MakeMKV-with-Linux solution.

General Strategy

MakeMKV has a, "preferences" dialog, allowing end-users to change different settings. On the "Advanced" tab, there is an entry titled, Output file name template:

TODO - show default template

By combining the use of the "name" of the disc with different Output Filename Template patterns, one can ease how TV show episodes are named.

Assumptions for this HOW-TO

  • You are going to transcode a TV show named, "My Foobar Honey"
  • With Season 1(one), produced in the year 2005.
    • The recommended approach for naming a TV show episode can be found at Naming video files/TV shows.
    • Which means that the first episode of the first season would be named: My Foobar Honey (2005) S01E01
  • Season 1(one) of the show is delivered with two discs. Both discs have three episodes each.

High level outline of the steps taken

  1. Adjust MakeMKV to save the first disc conforming to Kodi's TV Show naming conventions.
    1. Setup the Output file name template for the first disc.
    2. Set the name of the disc to the TV Show name, year of the season being transcoded.
  2. Transcode the first disc.
  3. Adjust the MakeMKV's Output file name template for the second disc
    1. The template will use a "pattern" that offsets from where the last disc transcoded left off.
    2. Since the prior transcode stopped at three(3), the offset is "4".
  4. Transcode the second disc.
  5. From CLI, move the second disc's episode to conform with Kodi's TV Show naming conventions.
  6. BONUS: Reset MakeMKV's default template pattern!

Example using Linux

Adjust MakeMKV for the first disc.

    1. Change the pattern in the output file template from:
          {NAME1}{-:CMNT1}{-:DT}{title:+DFLT}{_t:N2}
    2. To:
          {NAME} S1E{M2}
    3. Set the "name" of the disc to: My Foobar Honey (2005)

Transcode the first disc.

    1. The result, using our example setup, will result in three files:

Adjust MakeMKV for the second disc.

    1. Determine the "offset". As the first disc result in 3(three) files, the "offset" is 3(three).
    2. Incorporate the "offset" into the template pattern. The prior pattern of: {NAME} S1E{M2}
    3. Becomes: {NAME} S1E-3-{M2}

Transcode the second disc.

    1. The result, using our example setup, will result in three additional files:

Using some "shell" wizardry, rename the new files.

Line Command
1 OFFSET=3
2 for PRIOR_NAME in *-${OFFSET}-*;do
3   ADJUST=$(printf "%02d" $(($(echo -n ${PRIOR_NAME}|sed -E -e "s/^.*-${OFFSET}-(.*)\.mkv$/\1/g")+OFFSET)))
4   NEW_NAME=$(echo -n ${PRIOR_NAME}|sed -E -e "s/^(.*)-${OFFSET}-.*$/\1${ADJUST}.mkv/g")
5   mv -i "$PRIOR_NAME" "$NEW_NAME"
6 done
  1. Each line explained in detail
    1. Set a variable named OFFSET to the value of 3.
    2. Loop over all the files in the current directory that match the GLOB pattern of *-3-*, and for each one found do..
    3. Handle in three sub-shells:
      1. echo the file name into sed and substitute out all but the "session" part of the name.
      2. With that result, add the OFFSET of "3" to the value found.
      3. With that result, pad it out with a leading "0".
    4. Using the PRIOR_NAME of the file, substitute the "new" to-be-used name.
    5. Move the file and for each one use the "-i" option to ensure existing files are not overwritten.

Final Results

After executing the above shell commands, the directory contents will now be: