Komet / MediaElch

Media Manager for Kodi
https://mediaelch.github.io/mediaelch-doc/about.html
GNU Lesser General Public License v3.0
825 stars 93 forks source link

Improved File Renamer #436

Open bugwelle opened 6 years ago

bugwelle commented 6 years ago

This was originally requested on the old MediaElch forum

It would be great if you could consider improving the file renaming tool in MediaElch to include the following features:

  1. Rename at the moment of scraping info (not in two separate tools, actions)
  2. Rename files and folders at the same time (starting with files, ending with folders)
  3. Include episode name (according to scrapper selected) in a file and/or folder renaming
  4. Adding a custom suffix (IE: 1080p.WEB-DL.EAC3-5.1.x264)
  5. The option to replace "spaces" with "periods"
  6. Be able to remove diacritics in files name and folders name

Other feature requests:

bugwelle commented 5 years ago

Personally I really like tinyMediaManager's renamer:

tmm renamer

bugwelle commented 5 years ago

Suggestions for a new renamer

Movies

Key-Types

Modifiers

Given title: "Big Buck Bunny (2008), 10min, Rating: 9.768"

Type Key Example
String ${title} Big Buck Bunny
Substring ${title:3 } Big
Character ${title[0]} B
String Literal my string, ${"my string"} my string
Bool ${3D ? ${title} } Big Buck Bunny or empty
Bool with alternative ${3D ? ${title} : "no-3d" } Big Buck Bunny or no-3d
Integer ${year} 2008
Integer: left pad with 0 ${minutes:4} 0010
Float ${rating} 9.65 (default: width=2)
Float + width ${rating.2} 9.6

Rules

Alternative: http://mustache.github.io would be good idea as well work in progress

Stis commented 3 years ago

Hello! A little something that bothers me with some non-english languages: trailing spaces. For example if the title of a movie is "Quoi de neuf ?", the filename will be "Year - Quoi de neuf .avi".

The problem doesn't appear in english where there is no spaces in front of double punctuations.

Did I miss how to set the renamer to exclude those trailing spaces or do you need to fix the code?

Thank you for all the work!

bugwelle commented 3 years ago

Must be fixed on our side. Thanks for reporting. :-)

Stis commented 3 years ago

Ok, nice. I can't wait the update! ;)

silvus commented 2 years ago

Hi,

This look like a nice improvement.

I try to organize movies by genres folders, can you also support the "genre" tag too please ?

It's a little different from the studio implementation since here we probably only need to use the first tag, so the template implementation is needed.

For now, the genre tags seem to be arranged in alphabetical order, so maybe in the long run a possibility to reorder them manually?

Stis commented 1 year ago

Hello. Back then I edited all my files by hand, even if I'm pretty sure I did some tests.

In 2.8.2 I see the old behaviour, trailing spaces remain. Since 2.8.4 it's ok, they're removed. BUT not totally.

If is "Quoi de neuf ", yes, this trailing space will be removed and the filename be "Quoi de neuf.ext" If <title> is "Quoi de neuf ? ", so the trailing spaces will be removed, then the final interrogation point will be too since it can't be in a filename, then my filename will be "Quoi de neuf .ext"</p> <p>With all my files edited by hand, I just re-encountered this problem now. ^^'</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/bugwelle"><img src="https://avatars.githubusercontent.com/u/1667306?v=4" />bugwelle</a> commented <strong> 1 year ago</strong> </div> <div class="markdown-body"> <p>hmm.. That shouldn't happen. <code>sanitizeFilename()</code> removes trailing/leading whitespace last, after replacing the <code>?</code>. Thanks for reporting!</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/bugwelle"><img src="https://avatars.githubusercontent.com/u/1667306?v=4" />bugwelle</a> commented <strong> 1 year ago</strong> </div> <div class="markdown-body"> <p>I will try to improve the renamer this year. I will use this issue as a log for personal notes, etc. If you don't want notifications, you can disable them via GitHub (on the right side in this issue).</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/bugwelle"><img src="https://avatars.githubusercontent.com/u/1667306?v=4" />bugwelle</a> commented <strong> 1 year ago</strong> </div> <div class="markdown-body"> <p>I write about a new concept here a bit: <a href="https://github.com/Komet/MediaElch/pull/1576">https://github.com/Komet/MediaElch/pull/1576</a> Feel free to add comments. It's work in progress.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/mihawk90"><img src="https://avatars.githubusercontent.com/u/556162?v=4" />mihawk90</a> commented <strong> 8 months ago</strong> </div> <div class="markdown-body"> <p>Another one for the wishlist:</p> <p>A "search and replace" type function to manually strings to replace. As an example I have several TV series with external subtitles, however they aren't recognised by Jellyfin because they are using a "wrong" format:</p> <pre><code>$ ls -1 rsg-fargo-s01e02-1080p-eng.idx rsg-fargo-s01e02-1080p-eng.sub rsg-fargo-s01e02-1080p-forced.idx rsg-fargo-s01e02-1080p-forced.sub rsg-fargo-s01e02-1080p.idx rsg-fargo-s01e02-1080p.mkv rsg-fargo-s01e02-1080p.sub</code></pre> <p>Notice the <code>-</code> in the filename as a separator at the end, but Jellyfin requires a <code>.</code> to separate these flags: <a href="https://jellyfin.org/docs/general/server/media/external-files#naming-flags">https://jellyfin.org/docs/general/server/media/external-files#naming-flags</a></p> <p>Ideally the renamer could grab the language identifier from the <code>idx</code> file and apply it to both <code>idx</code> and <code>sub</code>, but since that would presumably require a lot more work, it would be nice to at least be able to replace <code>-eng</code> with <code>.eng</code>, and <code>-forced</code> with <code>.forced</code> (or <code>.ger.forced</code> in this case).</p> <p>edit: On that note, it might be cool to have these external files listed in the Stream Details tab so the user can adjust those flags (whether that be a selection field or free-form-input).</p> <p>I also forgot to mention this should also apply to <a href="https://kodi.wiki/view/External_audio_tracks">External Audio Tracks</a>, which currently aren't picked up at all:</p> <pre><code>$ ls -1 | grep S01E01 S01E01.ac3 S01E01.mkv S01E01.nfo</code></pre> <p><img src="https://github.com/Komet/MediaElch/assets/556162/b6d89604-e7f3-4ba6-8bd9-10238f4acd51" alt="image" /></p> <p>edit: I just noticed there is already an issue for this:</p> <h1>1044</h1> <p>I don't know how the Renamer currently picks files to rename but it seems to me like a lot of special case handling. I might be wrong on this but I feel like a shotgun approach wouldn't actually be bad in this case, i.e. just getting the current filename (minus extension) and grabbing every single filename that starts with that same string. That way ME doesn't need special handling for specific filetypes or care about suffixes in the filename at all and users can throw any kind of file they like at it, as long as ME preserves the suffixes. I currently do some of that with <code>sed</code> where I just swap out specific parts of the filename that I need.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/bugwelle"><img src="https://avatars.githubusercontent.com/u/1667306?v=4" />bugwelle</a> commented <strong> 8 months ago</strong> </div> <div class="markdown-body"> <p>Notes to self: <a href="https://en.wikipedia.org/wiki/Filename#Comparison_of_filename_limitations">https://en.wikipedia.org/wiki/Filename#Comparison_of_filename_limitations</a></p> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>