Renaming One Pace to fit One Piece episodes

All about user-defined episode / movie / file name format expressions
Post Reply
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Renaming One Pace to fit One Piece episodes

Post by devster »

Hello, I recently found the One Pace project and was wondering how to make it fit to the original One Piece episode list.
The original files are named:

Code: Select all

./[One Pace][1-7] Romance Dawn [1080p]/[One Pace][1] Romance Dawn 01 [1080p][FB72C13F].mkv
./[One Pace][8-21] Orange Town [1080p]/[One Pace][8-11] Orange Town 01 [1080p][2388DB63].mkv
...
and this is a sample output:

Code: Select all

filebot -rename --db TheMovieDB::TV --action TEST --format  '{plex.derive("[$crc32]") << " [$sn]"}' --order 'Story Arc' --output .. --q 'One Piece 1999'  -non-strict \[One\ Pace\]\[1-7\]\ Romance\ Dawn\ \[1080p\]
* Consider using --mode interactive to enable interactive mode
Rename episodes using [TheMovieDB] with [Story Arc]
Lookup via [One Piece 1999]
Fetching episode data for [One Piece #37854]
└─ 1101 episodes
[TEST] from [One Pace/files/[One Pace][1-7] Romance Dawn [1080p]/[One Pace][1] Romance Dawn 01 [1080p][FB72C13F].mkv] to [One Pace/TV Shows/One Piece/Season 01 [Romance Dawn]/One Piece - S01E01 - I'm Luffy! The Man Who Will Become the Pirate King![FB72C13F].mkv]
[TEST] from [One Pace/files/[One Pace][1-7] Romance Dawn [1080p]/[One Pace][2] Romance Dawn 02 [1080p][667784D2].mkv] to [One Pace/TV Shows/One Piece/Season 01 [Romance Dawn]/One Piece - S01E02 - The Great Swordsman Appears! Pirate Hunter, Roronoa Zoro[667784D2].mkv]
[TEST] from [One Pace/files/[One Pace][1-7] Romance Dawn [1080p]/[One Pace][3-5] Romance Dawn 03 [1080p][8F0ACC44].mkv] to [One Pace/TV Shows/One Piece/Season 01 [Romance Dawn]/One Piece - S01E03 - Morgan VS Luffy! Who's This Beautiful Young Girl[8F0ACC44].mkv]
[TEST] from [One Pace/files/[One Pace][1-7] Romance Dawn [1080p]/[One Pace][5-7] Romance Dawn 04 [1080p][9A48E3EB].mkv] to [One Pace/TV Shows/One Piece/Season 50 [Wano Country Part 2]/One Piece - S50E11 - Romance Dawn[9A48E3EB].mkv]
However the actual episode number is not available in the file name and the [5-7] within the second square brackets refers to manga chapters; moreover the name of the episode is usually <Story Arc> <anime episode> (e.g. Romance Dawn 02).

This is the ideal output I'm looking for:

Code: Select all

[TEST] from [One Pace/files/[One Pace][1-7] Romance Dawn [1080p]/[One Pace][1] Romance Dawn 01 [1080p][FB72C13F].mkv] to [One Pace/Anime/One Piece/Specials/One Piece - S26 - Episode of East Blue - Luffy and His Four Friends` Great Adventure [FB72C13F].mkv]
[TEST] from [One Pace/files/[One Pace][1-7] Romance Dawn [1080p]/[One Pace][2] Romance Dawn 02 [1080p][667784D2].mkv] to [One Pace/Anime/One Piece/Romance Dawn Arc/One Piece - 001 - I`m Luffy! The Man Who`s Gonna Be King of the Pirates! [667784D2].mkv]
[TEST] from [One Pace/files/[One Pace][1-7] Romance Dawn [1080p]/[One Pace][3-5] Romance Dawn 03 [1080p][8F0ACC44].mkv] to [One Pace/Anime/One Piece/Romance Dawn Arc/One Piece - 002 - Enter the Great Swordsman! Pirate Hunter Roronoa Zoro! [8F0ACC44].mkv]
[TEST] from [One Pace/files/[One Pace][1-7] Romance Dawn [1080p]/[One Pace][5-7] Romance Dawn 04 [1080p][9A48E3EB].mkv] to [One Pace/Anime/One Piece/Romance Dawn Arc/One Piece - 003 - Morgan vs. Luffy! Who`s the Mysterious Pretty Girl? [9A48E3EB].mkv]
It was reconstructed manually using a json file available on the website which contains all available details for renaming and has the following structure for each arc:

Code: Select all

$ jq '.props.pageProps.arcs[0]' pace.json
{
  "anime_episodes": "2-3, 504, Episode of Luffy",
  "downloads": [
    {
      "id": "clo9k28pq000ra21is6z0jzqf",
      "translations": [],
      "type": "MAGNET",
      "uri": "https://api.onepace.net/download/magnet.php?hash=d42d71270da00dd578e34fb28517a5fffe4d2cfb"
    },
    {
      "id": "clo9k28pq000sa21icmlibbat",
      "translations": [],
      "type": "TORRENT",
      "uri": "https://api.onepace.net/download/torrent.php?hash=d42d71270da00dd578e34fb28517a5fffe4d2cfb"
    },
    {
      "id": "clo9k28u20019a21iqh0omn44",
      "translations": [
        {
          "language_code": "en",
          "text": "English 480p/720p"
        }
      ],
      "type": "TELEGRAM",
      "uri": "https://t.me/+7ifpylWh7I0zNzBk"
    }
  ],
  "duration": "1:23:30",
  "episodes": [
    {
      "anime_episodes": "Episode of East Blue, 312 (Intro)",
      "downloads": [
        {
          "id": "clo9k2r4002k1a21iz69r8xpa",
          "translations": [],
          "type": "MAGNET",
          "uri": "https://api.onepace.net/download/magnet.php?hash=d42d71270da00dd578e34fb28517a5fffe4d2cfb"
        },
        {
          "id": "clo9k2r4002k2a21i6jogofos",
          "translations": [],
          "type": "TORRENT",
          "uri": "https://api.onepace.net/download/torrent.php?hash=d42d71270da00dd578e34fb28517a5fffe4d2cfb"
        },
        {
          "id": "clo9k2r7m02kja21il9n8m1nx",
          "translations": [
            {
              "language_code": "en",
              "text": "English 480p/720p"
            }
          ],
          "type": "TELEGRAM",
          "uri": "https://t.me/c/1513089154/16"
        }
      ],
      "duration": "18:17",
      "id": "clo9k2r4002k0a21irauee0qc",
      "images": [
        {
          "mimeType": "image/webp",
          "src": "cover-romance-dawn-01.webp",
          "width": 720
        }
      ],
      "invariant_title": "Romance Dawn 01",
      "manga_chapters": "1",
      "part": 1,
      "released_at": "2020-12-02T12:00:00.000Z",
      "resolution": "1080p",
      "translations": [
        {
          "description": "بعد أن تأثر بالقرصان ذو الشعر الأحمر شانكس الذي يرتدي قبعة قش، يتبع الفتى المتحمس مونكي دي. لوفي أحلامه في أن يصبح ملك القراصنة ذات يوم",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "ar",
          "title": "فجر الرومانسية، فجر  المغامرة"
        },
        {
          "description": "Beeinflusst von dem strohhuttragenden Piraten Rothaar Shanks, träumt ein begeisterter Junge namens Monkey D. Luffy davon, eines Tages König der Piraten zu werden.",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "de",
          "title": "Romance Dawn - Der Anfang eines Abenteuers"
        },
        {
          "description": "Influenced by the straw-hat-wearing pirate Red-Haired Shanks, an enthusiastic young boy named Monkey D. Luffy dreams of one day becoming king of the pirates.",
          "includes_dub": true,
          "includes_sub": true,
          "language_code": "en",
          "title": "Romance Dawn, the Dawn of an Adventure"
        },
        {
          "description": "Influenciado por un pirata llamado Shanks el Pelirrojo que porta un sombrero de paja, un entusiasta niño llamado Monkey D. Luffy sueña con algún día convertirse en el Rey de los Piratas.",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "es",
          "title": "El amanecer de la aventura"
        },
        {
          "description": "Influencé par le pirate Shanks le Roux, porteur d'un chapeau de paille, un jeune garçon enthousiaste nommé Monkey D. Luffy rêve de devenir un jour, le Roi des Pirates.",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "fr",
          "title": "L'Aube d'une Grande Aventure"
        },
        {
          "description": "Influenced by the straw-hat-wearing pirate Red-Haired Shanks, an enthusiastic young boy named Monkey D. Luffy dreams of one day becoming king of the pirates.",
          "includes_dub": true,
          "includes_sub": false,
          "language_code": "jp",
          "title": "ROMANCE DAWN - 冒険の夜明け"
        }
      ]
    },
    {
      "anime_episodes": "1",
      "downloads": [
        {
          "id": "clo9k2ev000sya21i5haqy7zr",
          "translations": [],
          "type": "MAGNET",
          "uri": "https://api.onepace.net/download/magnet.php?hash=d42d71270da00dd578e34fb28517a5fffe4d2cfb"
        },
        {
          "id": "clo9k2ev000sza21ituq0gyc4",
          "translations": [],
          "type": "TORRENT",
          "uri": "https://api.onepace.net/download/torrent.php?hash=d42d71270da00dd578e34fb28517a5fffe4d2cfb"
        },
        {
          "id": "clo9k2eyo00tga21ifmh5q4xj",
          "translations": [
            {
              "language_code": "en",
              "text": "English 480p/720p"
            }
          ],
          "type": "TELEGRAM",
          "uri": "https://t.me/c/1513089154/17"
        }
      ],
      "duration": "19:41",
      "id": "clo9k2ev000sxa21i8w1kxbnx",
      "images": [
        {
          "mimeType": "image/webp",
          "src": "cover-romance-dawn-02.webp",
          "width": 720
        }
      ],
      "invariant_title": "Romance Dawn 02",
      "manga_chapters": "2",
      "part": 2,
      "released_at": "2020-12-02T12:00:00.000Z",
      "resolution": "1080p",
      "translations": [
        {
          "description": "بينما ألفيدا وقراصنتها ينهبون سفينة رحلات، يجدون برميل يحتوي داخله فتى يدعى مونكي دي.لوفي، يصادق الجبان كوبي لوفي ويتحدثون عن أحلامهما فيما بينهما",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "ar",
          "title": "يسمونه لوفي المشهور بـ (قبعة القش)"
        },
        {
          "description": "Während Alvida und ihre Piraten ein Kreuzfahrtschiff plündern, stoßen sie auf ein Fass mit einem seltsamen Jungen namens Monkey D. Luffy.  Der schüchterne Koby freundet sich mit Luffy an, und sie teilen ihre großen Träume miteinander.",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "de",
          "title": "Hier kommt \"Strohhut\" Luffy!"
        },
        {
          "description": "While Alvida and her pirates plunder a cruise ship, they come across a barrel containing a strange boy named Monkey D. Luffy. The timid Koby befriends Luffy, and they share their grand dreams with each other.",
          "includes_dub": true,
          "includes_sub": true,
          "language_code": "en",
          "title": "They Call Him \"Straw Hat\" Luffy"
        },
        {
          "description": "Mientras Alvida y sus piratas saquean un crucero, encuentran un barril que contenía un extraño muchacho llamado Monkey D. Luffy. El tímido Koby se hace amigo de este, y comparten sus sueños el uno con el otro.",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "es",
          "title": "Luffy, el hombre del sombrero de paja"
        },
        {
          "description": "Alors qu'Alvida et ses pirates pillent un bateau de croisière, ils tombent sur un tonneau contenant un étrange garçon nommé Monkey D. Luffy. Le timide Kobby se lie d'amitié avec Luffy, et ils partagent leurs grands rêves.",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "fr",
          "title": "On le surnomme \"Chapeau de paille\""
        },
        {
          "description": "While Alvida and her pirates plunder a cruise ship, they come across a barrel containing a strange boy named Monkey D. Luffy. The timid Koby befriends Luffy, and they share their grand dreams with each other.",
          "includes_dub": true,
          "includes_sub": false,
          "language_code": "jp",
          "title": "その男\"麦わらのルフィ\""
        }
      ]
    },
    {
      "anime_episodes": "2, 19",
      "downloads": [
        {
          "id": "clo9k2hc8015ba21icjanbwa9",
          "translations": [],
          "type": "MAGNET",
          "uri": "https://api.onepace.net/download/magnet.php?hash=d42d71270da00dd578e34fb28517a5fffe4d2cfb"
        },
        {
          "id": "clo9k2hc8015ca21ijsmujxyx",
          "translations": [],
          "type": "TORRENT",
          "uri": "https://api.onepace.net/download/torrent.php?hash=d42d71270da00dd578e34fb28517a5fffe4d2cfb"
        },
        {
          "id": "clo9k2hfv015ta21i6pfxva0t",
          "translations": [
            {
              "language_code": "en",
              "text": "English 480p/720p"
            }
          ],
          "type": "TELEGRAM",
          "uri": "https://t.me/c/1513089154/18"
        }
      ],
      "duration": "27:34",
      "id": "clo9k2hc8015aa21iacxfdoou",
      "images": [
        {
          "mimeType": "image/webp",
          "src": "cover-romance-dawn-03.webp",
          "width": 720
        }
      ],
      "invariant_title": "Romance Dawn 03",
      "manga_chapters": "3-4",
      "part": 3,
      "released_at": "2020-12-02T12:00:00.000Z",
      "resolution": "1080p",
      "translations": [
        {
          "description": "باحثًا عن أعضاء لطاقم قراصنته، يصل لوفي بصحبه صديق الجديد كوبي إلى جزيرة بها مقر للبحرية، وهناك يبحثون عن صائد القراصنة الشهير زورو ولكنه يعترضهم هيليمبو، ابن العقيد الشهير مورغان",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "ar",
          "title": "ملك القراصنة والسياف الأعظم"
        },
        {
          "description": "Auf der Suche nach Mitgliedern für seine Piratencrew gelangt Luffy mit seinem neuen Freund Koby auf eine Insel mit einer Marinefestung.  Dort spüren sie den berühmten Piratenjäger Zoro auf, geraten aber an Helmeppo, den Sohn des berüchtigten Kapitän Morgan.",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "de",
          "title": "Piratenkönig und Meisterschwertkämpfer"
        },
        {
          "description": "In search of members for his pirate crew, Luffy with his new friend Koby arrive at an island with a Navy stronghold. There, they track down the renowned Pirate Hunter Zoro but run afoul of Helmeppo, son of the infamous Captain Morgan.",
          "includes_dub": true,
          "includes_sub": true,
          "language_code": "en",
          "title": "The Pirate King and the Master Swordsman"
        },
        {
          "description": "Buscando miembros para su tripulación, Luffy, con su nuevo amigo, llegan a una isla controlada por la Marina. Pronto descubren que el famoso Cazador de Piratas Zoro, había sido arrestado por Helmeppo, el hijo del infame Capitán Morgan.",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "es",
          "title": "Rey Pirata y Maestro Espadachín"
        },
        {
          "description": "À la recherche de membres pour son équipage de pirates, Luffy et son nouvel ami Kobby arrivent sur une île avec un bastion de la Marine. Là, ils traquent le célèbre chasseur de pirates Zoro mais se heurtent à Hermep, fils du tristement célèbre capitaine Morgan.",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "fr",
          "title": "Le Roi des Pirates et le Grand Épéiste"
        },
        {
          "description": "In search of members for his pirate crew, Luffy with his new friend Koby arrive at an island with a Navy stronghold. There, they track down the renowned Pirate Hunter Zoro but run afoul of Helmeppo, son of the infamous Captain Morgan.",
          "includes_dub": true,
          "includes_sub": false,
          "language_code": "jp",
          "title": "海賊王と大剣豪"
        }
      ]
    },
    {
      "anime_episodes": "3",
      "downloads": [
        {
          "id": "clo9k2mp801wya21ic6yc501j",
          "translations": [],
          "type": "MAGNET",
          "uri": "https://api.onepace.net/download/magnet.php?hash=d42d71270da00dd578e34fb28517a5fffe4d2cfb"
        },
        {
          "id": "clo9k2mp801wza21is8m4fe7p",
          "translations": [],
          "type": "TORRENT",
          "uri": "https://api.onepace.net/download/torrent.php?hash=d42d71270da00dd578e34fb28517a5fffe4d2cfb"
        },
        {
          "id": "clo9k2msv01xga21ibjpiji7d",
          "translations": [
            {
              "language_code": "en",
              "text": "English 480p/720p"
            }
          ],
          "type": "TELEGRAM",
          "uri": "https://t.me/c/1513089154/19"
        }
      ],
      "duration": "17:58",
      "id": "clo9k2mp801wxa21ifng3yy9n",
      "images": [
        {
          "mimeType": "image/webp",
          "src": "cover-romance-dawn-04.webp",
          "width": 720
        }
      ],
      "invariant_title": "Romance Dawn 04",
      "manga_chapters": "5-7",
      "part": 4,
      "released_at": "2020-12-02T12:00:00.000Z",
      "resolution": "1080p",
      "translations": [
        {
          "description": "يُقنع لوفي زورو بأن ينضم لطاقم قراصنته، ولكن عليهم أولًا هزيمة العقيد الطاغية مورغان",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "ar",
          "title": "الأول"
        },
        {
          "description": "Luffy überredet den gefangenen Zoro, sich seiner Piratencrew anzuschließen, aber sie müssen erst den tyrannischen Kapitän Morgan besiegen.",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "de",
          "title": "Nummer Eins"
        },
        {
          "description": "Luffy convinces the captive Zoro to join his pirate crew, but they must first defeat the tyrannical Captain Morgan.",
          "includes_dub": true,
          "includes_sub": true,
          "language_code": "en",
          "title": "The First"
        },
        {
          "description": "Luffy convence al cautivo Zoro de que se una a su tripulación, pero primero deben derrotar al Capitán Morgan.",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "es",
          "title": "El primer miembro"
        },
        {
          "description": "Luffy convainc le captif Zoro de rejoindre son équipage de pirates, mais ils doivent d'abord vaincre le tyrannique capitaine Morgan.",
          "includes_dub": false,
          "includes_sub": true,
          "language_code": "fr",
          "title": "Le Premier"
        },
        {
          "description": "Luffy convinces the captive Zoro to join his pirate crew, but they must first defeat the tyrannical Captain Morgan.",
          "includes_dub": true,
          "includes_sub": false,
          "language_code": "jp",
          "title": "1人目"
        }
      ]
    }
  ],
  "id": "clo9k28pq000qa21idg55bphk",
  "images": [
    {
      "mimeType": "image/jpeg",
      "src": "cover-romance-dawn-arc.jpg",
      "width": 756
    },
    {
      "mimeType": "image/webp",
      "src": "cover-romance-dawn-arc.webp",
      "width": 756
    }
  ],
  "invariant_title": "Romance Dawn",
  "manga_chapters": "1-7",
  "part": 1,
  "released_at": "2020-12-02T12:00:00.000Z",
  "resolution": "1080p",
  "translations": [
    {
      "description": "ينطلق الفتى مونكي دي لوفي في مغامرة لتكوين طاقم من أجل العثور على كنز ون بيس الأسطوري ليصبح ملك القراصنة",
      "includes_dub": false,
      "includes_sub": true,
      "language_code": "ar",
      "title": "فجر الرومانسية"
    },
    {
      "description": "Monkey D. Luffy sets out on an adventure to form a crew, find the legendary One Piece, and become the pirate king.",
      "includes_dub": false,
      "includes_sub": true,
      "language_code": "de",
      "title": "Romance Dawn"
    },
    {
      "description": "Monkey D. Luffy sets out on an adventure to form a crew, find the legendary One Piece, and become the pirate king.",
      "includes_dub": true,
      "includes_sub": true,
      "language_code": "en",
      "title": "Romance Dawn"
    },
    {
      "description": "Monkey D. Luffy parte en su aventura para formar su tripulación, encontrar el legendario One Piece, y así, ser el Rey de los Piratas.",
      "includes_dub": false,
      "includes_sub": true,
      "language_code": "es",
      "title": "Romance Dawn"
    },
    {
      "description": "Monkey D. Luffy se lance dans une aventure pour former un équipage, trouver le légendaire One Piece et devenir le Roi des Pirates.",
      "includes_dub": false,
      "includes_sub": true,
      "language_code": "fr",
      "title": "Romance Dawn"
    },
    {
      "description": "Monkey D. Luffy sets out on an adventure to form a crew, find the legendary One Piece, and become the pirate king.",
      "includes_dub": true,
      "includes_sub": false,
      "language_code": "jp",
      "title": "ROMANCE DAWN"
    }
  ]
}
The arcs and episodes are ordered with the part key (1-indexed) and named with the invariant_title key, so the following is true:

Code: Select all

diff <(jq '.props.pageProps.arcs[0].episodes' pace.json) <(jq '.props.pageProps.arcs[] | select(.part == 1) | .episodes' pace.json)
I see a possible solution in reading the json file, matching the name from the invariant_title key to the filenames and using the anime_episodes key as episode number (if it has a hyphen it's a multi-episode, anything after commas to be ignored, but I can't figure out a way to do it.
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 23002
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming One Pace to fit One Piece episodes

Post by rednoah »

If each episode is cut down in length but otherwise aligns 1:1 then I'd just use the Desktop application for one-off tasks like this:

:idea: Please read the FAQ and How to Request Help.
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: Renaming One Pace to fit One Piece episodes

Post by devster »

rednoah wrote: 05 Nov 2023, 16:06 If each episode is cut down in length but otherwise aligns 1:1 then I'd just use the Desktop application for one-off tasks like this:
Unfortunately no, most episodes are re-cut using multiple original episodes (One Piece is over 1000 episodes and One Pace is less than 700 at the moment).
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 23002
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming One Pace to fit One Piece episodes

Post by rednoah »

If you must rename files based on some information in some JSON file, then Plain File Mode is the way to go, though you will need to write the code yourself. Maybe something akin to the [Plain File Mode] Batch Rename any type of file › Rename files based on sibling properties files example. The json() function can help you read JSON but otherwise you're on your own.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 23002
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming One Pace to fit One Piece episodes

Post by rednoah »

Here's some code to get you started:

Format: Select all

{
	def episode = json('pace.json').episodes.find{ fn.contains(it.invariant_title) }
	def numbers = episode.anime_episodes.matchAll(/\d+/)
	def translation = episode.translations.find{ it.language_code == /en/ }

	"${numbers*.pad(3).join('-')} ${translation.title}"
}
Screenshot
:idea: Please read the FAQ and How to Request Help.
Post Reply