ShokoAnime / ShokoServer

Repository for Shoko Server.
https://shokoanime.com/
MIT License
404 stars 74 forks source link

Renamer dropping apostrophes from series name #755

Open deusxanime opened 6 years ago

deusxanime commented 6 years ago

VERSION INFORMATION

Server Version: latest stable/release docker (3.9.2?)

Desktop Version: 3.9.2

If you've compiled your own version, please use the last commit you compiled.

LOG FILE

[2018-08-30 09:10:15:978] Info|MonoMethod.InternalInvoke => ShokoServiceImplementation.RenameAndMoveFile => SVR_VideoLocal_Place.RenameFile Renaming file From (/data/anime/Chi's Sweet Adventure - Season 2 [anidb2-13488]/[HorribleSubs] Chi's Sweet Adventure S2 - 20 [720p].mkv) to (/data/anime/Chi's Sweet Adventure - Season 2 [anidb2-13488]/Chis Sweet Adventure - Season 2 - Ep 20 (1280x720) [HorribleSubs] [E324F926].mkv)....

DESCRIPTION

When using Renamer, series with apostrophe in their name are missing the character.

Example 1: Series - Koneko no Chii: Ponponraa Dairyokou Should rename to (English) - Chi's Sweet Adventure: Season 2 Renames to - Chis Sweet Adventure - Season 2

Example 2: Series - Shoujo Shuumatsu Ryokou Should rename to (English) - Girls' Last Tour Renames to - Girls Last Tour

STEPS TO REPRODUCE

Try to rename a file from a series with an apostrophe in the name using the Renamer.

da3dsoul commented 6 years ago

It's a known issue. I don't remember if it's already on GitHub, though

da3dsoul commented 6 years ago

I don't see it. The best way to solve it on our end is to implement #504, but we've got a lot of other things going on right now

deusxanime commented 6 years ago

I searched but didn't see anything on it. I might have mentioned awhile back on discord, but wasn't sure so figured I should open an actual issue. Glad to know you are aware and hopefully will get fixed eventually. Thanks!

purposelycryptic commented 6 years ago

I realize this is about a month late, but I just saw this, and thought I'd add what little I did notice regarding the issue while I was figuring out how to add support for romanized Chinese and Korean series names in the Renamer (I know someone who really likes Manhua/Manwhua adaptations, and the English titles are terrible).

Anyway, it's a very odd bug - what (I think) it should be doing is taking the ` character that AniDB loves using in place of an Apostrophe, and replacing it with a regular ' as part of the final filename construction, here (around Line 1380-1410 of LegacyRename.cs, I think? I've added stuff to mine, so the line numbers no longer match):

return Utils.ReplaceInvalidFolderNameCharacters($"{newFileName.Replace("`", "'")}{ext}");

But instead, it removes both versions of the Apostrophe from any string added to the filename, but allows for the ` version to be manually added as part of the script (I've just been calling it the "AniDB Apostrophe", because AniDB turns any regular Apostrophe into one of those, everywhere from Series and Episode names to forum posts to metadata entries), while any normal Apostrophe is ignored, which seems like the opposite of expected behavior.

Sadly, that is all I have - I went through the various model and utils functions related to the renamer, but couldn't find anything there, and the LegacyRenamer.cs just has way too many substring functions that use the Apostrophe for... something, as part of the string index location parts of the add/replace functions, but the limits of my coding knowledge mean I can't even really understand if that is in any way related, or if it is simply a standard symbol used for that class of function.

I need more learning, but there's always too much work :-\

da3dsoul commented 6 years ago

Oh I know how to fix it. I just haven't because no one's seriously asked me to. The people that really care make their own DLL from @cazzar's example.

I'm actually interested in your project. Let me know how it goes. We may implement it deeper into Server if it's successful and not impractical.

da3dsoul commented 6 years ago

Also that's called a grave apostrophe

da3dsoul commented 6 years ago

AniDB claims that they use it to avoid needing to escape apostrophes in everything, but I'm skeptical

purposelycryptic commented 6 years ago

Sorry for taking a while to get back; work, it just never ends...

I actually had no clue there was a sample renamer base just sitting there, waiting to be used - I think I remember seeing you mentioning the idea of using custom renamer DLLs eventually in some issue thread, but that was somewhere between a few months to years ago (My memory is kind of flaky); I'll definitely be checking it out.

RE my little project to add X-KOT and X-ZHT titles for the renamer, at the moment it does everything other than actually add the title in the renamer - which is its purpose, so its usefulness is zero as is, but I think/hope it's just a simple matter of sleep-deprivation and forgetting to edit anything from the part that actually subs the tag with the title; the tag/title should be exposed for use, I just didn't actually write anything to use it.

If you're curious, I pushed the changes to a new branch of my fork here.

purposelycryptic commented 6 years ago

PS, AniDB definitely just wants to be unique and special with their grave apostrophe usage - that thing should stay on top of letters where it belongs, it's a diacritic, not an alternate apostrophe, dangit :)

deusxanime commented 4 years ago

So it's coming up on a couple years and there is not new renamer yet and this isn't fixed. Any chance of putting the fix in for it in the legacy renamer? Sounds like you already know how to do it based on some comments above and just would be matter of updating the code?

I know you've said we can create custom/personal renamers but I have little to no coding knowledge, much less how to compile into a DLL. I'm not trying to have you completely re-write it I think, but just fix a (hopefully) simple bug. I know apostrophes worked fine back in the JMM days and I still run an old JMM server just to do my renaming.

I'm running this in docker on unRAID actually, so even if I did create my own DLL, wouldn't it get overwritten any time there was an update to the container?

Cazzar commented 4 years ago

If you created your own dll, you can put it in a volume mounted in the right directory and it won't get updated between container updates, I do this myself on my Linux server

As for fixing this, we might get around to it soon, but we are currently working on trying to port the codebase to .net standard/core but I might add this to a "Good first issue" tag as it should be relatively easy to fix