AMC Script is not copying extracted subtitles?

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
plum117
Posts: 2
Joined: 17 Dec 2017, 20:31

AMC Script is not copying extracted subtitles?

Post by plum117 »

Hi,

First, this amc script extracting file is wonderful and really helpful. I was able to use it with my needs and have everything automated so my media are ready to use in plex!!

The last thing I'm not sure to understand is why the subtitles are ignored when extracting and copying a media files? I would like the subtitles contained in the zip file to be copied, but instead the amc script seems to intentionally "ignore orphaned subtitles". I find this quite unfortunate, since I need to copy manually those subtitles! More over, I would like better use the subtitles found in the zip file (instead of any downloaded) since I'm sure they fit with the media!

Is there anyway to have the amc script copy those subtitles?

Thanks

Command use:

Code: Select all

filebot -script fn:amc --output "E:/Users/plum/Media" --action copy --conflict auto -non-strict --log-file "E:/Users/plum/Media/amc.log" -r --def unsorted=y plex=127.0.0.1:1H693TG1GHsKa9NBCWCz clean=y extractFolder="E:/Users/plum/Downloads/torrent/ZipExtractions"  "ut_label=Torrent Leech" "ut_state=20" "ut_title=The.Walking.Dead.S08E09.CONVERT.1080p.WEB.h264-TBS" "ut_kind=multi" "ut_dir=E:\Users\plum\Downloads\torrent\Stronger.2017.1080p.BluRay.x264-GECKOS"
Logs:

Code: Select all

Run script [fn:amc] at [Sun Mar 04 15:00:58 EST 2018]
Parameter: unsorted = y
Parameter: plex = *****
Parameter: mailto = *****
Parameter: reportError = y
Parameter: storeReport = y
Parameter: clean = y
Parameter: extractFolder = E:/Users/plum/Downloads/torrent/ZipExtractions
Parameter: ut_label = Torrent Leech
Parameter: ut_state = 20
Parameter: ut_title = The.Walking.Dead.S08E09.CONVERT.1080p.WEB.h264-TBS
Parameter: ut_kind = multi
Parameter: ut_dir = E:\Users\plum\Downloads\torrent\Stronger.2017.1080p.BluRay.x264-GECKOS
Ignore extra: E:\Users\plum\Downloads\torrent\Stronger.2017.1080p.BluRay.x264-GECKOS\Sample
Read archive [stronger.2017.1080p.bluray.x264-geckos.rar] and extract to [E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos\Stronger.2017.1080p.BluRay.x264-GECKOS]
Extracting files [E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos\Stronger.2017.1080p.BluRay.x264-GECKOS\Stronger.2017.1080p.BluRay.x264-GECKOS.mkv]
Ignore orphaned subtitles: E:\Users\plum\Downloads\torrent\Stronger.2017.1080p.BluRay.x264-GECKOS\Subs\stronger.2017.1080p.bluray.x264-geckos.subs\Subs\Stronger.2017.1080p.BluRay.x264-GECKOS.idx
Ignore orphaned subtitles: E:\Users\plum\Downloads\torrent\Stronger.2017.1080p.BluRay.x264-GECKOS\Subs\stronger.2017.1080p.bluray.x264-geckos.subs\Subs\stronger.2017.1080p.bluray.x264-geckos\Subs\Stronger.2017.1080p.BluRay.x264-GECKOS.sub
Read archive [stronger.2017.1080p.bluray.x264-geckos.rar] and extract to [E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos\Subs]
Extracting files [E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos\Subs\Stronger.2017.1080p.BluRay.x264-GECKOS.sub]
Ignore orphaned subtitles: E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos\Subs\Stronger.2017.1080p.BluRay.x264-GECKOS.sub
Read archive [stronger.2017.1080p.bluray.x264-geckos.subs.rar] and extract to [E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos.subs\Subs]
Extracting files [E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos.subs\Subs\stronger.2017.1080p.bluray.x264-geckos.rar, E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos.subs\Subs\Stronger.2017.1080p.BluRay.x264-GECKOS.idx]
Ignore orphaned subtitles: E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos.subs\Subs\Stronger.2017.1080p.BluRay.x264-GECKOS.idx
Read archive [stronger.2017.1080p.bluray.x264-geckos.rar] and extract to [E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos\Subs]
Skipped extracting files [E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos\Subs\Stronger.2017.1080p.BluRay.x264-GECKOS.sub]
Input: E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos\Stronger.2017.1080p.BluRay.x264-GECKOS\Stronger.2017.1080p.BluRay.x264-GECKOS.mkv
Group: [mov:stronger 2017] => [Stronger.2017.1080p.BluRay.x264-GECKOS.mkv]
Rename movies using [TheMovieDB]
Auto-detect movie from context: [E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos\Stronger.2017.1080p.BluRay.x264-GECKOS\Stronger.2017.1080p.BluRay.x264-GECKOS.mkv]
[COPY] From [E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos\Stronger.2017.1080p.BluRay.x264-GECKOS\Stronger.2017.1080p.BluRay.x264-GECKOS.mkv] to [E:\Users\plum\Media\Movies\Stronger (2017)\Stronger (2017).mkv]
Processed 1 files
Notify Plex: [host:127.0.0.1, token:1H693TG1GHsKa9NBCWCz]
GET: http://127.0.0.1:32400/library/sections/all/refresh?X-Plex-Token=1H693TG1GHsKa9NBCWCz
Saving report as C:\Users\plum\AppData\Roaming\FileBot\reports\[2018-03-04_15_03]_The_Walking_Dead_S08E09_CONVERT_1080p_WEB_h264-TBS.html
Clean temporary extracted files
Delete E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos.subs\Subs\Stronger.2017.1080p.BluRay.x264-GECKOS.idx
Delete E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos.subs\Subs\stronger.2017.1080p.bluray.x264-geckos.rar
Delete E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos\Stronger.2017.1080p.BluRay.x264-GECKOS\Stronger.2017.1080p.BluRay.x264-GECKOS.mkv
Delete E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos\Subs\Stronger.2017.1080p.BluRay.x264-GECKOS.sub
Delete E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos.subs
Delete E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos
Delete E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos
Delete E:\Users\plum\Downloads\torrent\ZipExtractions\stronger.2017.1080p.bluray.x264-geckos
Done ヾ(@⌒ー⌒@)ノ
plum117
Posts: 2
Joined: 17 Dec 2017, 20:31

Re: AMC Script is not copying extracted subtitles?

Post by plum117 »

From the github code, it seems that the sub needs to be in the same folder or a child folder of where the media is. However, with all those zip files contained in different folders and the way they get unzip, it is quite hard to meet this rule.

Anyway, I was able to find a workaround by copying the \Subs\stronger.2017.1080p.bluray.x264-geckos.subs.rar into the parent folder. By doing, the *.sub file is found by filebot and copied.

Note that this magic seems to work since inside \Subs\stronger.2017.1080p.bluray.x264-geckos.subs.rar there is another zip named stronger.2017.1080p.bluray.x264-geckos.rar which holds the .sub. After copying the subs.rar into the parent folder, then the stronger.2017.1080p.bluray.x264-geckos.rar containing the .sub file gets unzip aside the media file, explaining why filebot accept the sub file.

For better understanding
Original structure:

Code: Select all

\Stronger.2017.1080p.BluRay.x264-GECKOS\stronger.2017.1080p.bluray.x264-geckos.rar --> contains Stronger.2017.1080p.BluRay.x264-GECKOS.mkv
\Stronger.2017.1080p.BluRay.x264-GECKOS\Subs\stronger.2017.1080p.bluray.x264-geckos.subs.rar --> contains stronger.2017.1080p.bluray.x264-geckos.rar\Stronger.2017.1080p.BluRay.x264-GECKOS.sub
When extracting original structure we have: (sub file ends in \Subs which is not even a child directory of Stronger.2017.1080p.BluRay.x264-GECKOS):

Code: Select all

\stronger.2017.1080p.bluray.x264-geckos\Stronger.2017.1080p.BluRay.x264-GECKOS\Stronger.2017.1080p.BluRay.x264-GECKOS.mkv 
\stronger.2017.1080p.bluray.x264-geckos.subs\Subs\stronger.2017.1080p.bluray.x264-geckos.rar
\stronger.2017.1080p.bluray.x264-geckos\Subs\Stronger.2017.1080p.BluRay.x264-GECKOS.sub
After copying Stronger.2017.1080p.BluRay.x264-GECKOS\Subs\*.rar to \Stronger.2017.1080p.BluRay.x264-GECKOS
Then the structure is:

Code: Select all

\Stronger.2017.1080p.BluRay.x264-GECKOS\stronger.2017.1080p.bluray.x264-geckos.rar --> contains Stronger.2017.1080p.BluRay.x264-GECKOS.mkv
\Stronger.2017.1080p.BluRay.x264-GECKOS\stronger.2017.1080p.bluray.x264-geckos.subs.rar --> contains stronger.2017.1080p.bluray.x264-geckos.rar\Stronger.2017.1080p.BluRay.x264-GECKOS.sub
And the resulted extraction is giving: (where now the mkv and sub are side by side)

Code: Select all

\stronger.2017.1080p.bluray.x264-geckos\Stronger.2017.1080p.BluRay.x264-GECKOS\Stronger.2017.1080p.BluRay.x264-GECKOS.mkv
\stronger.2017.1080p.bluray.x264-geckos\Stronger.2017.1080p.BluRay.x264-GECKOS\Stronger.2017.1080p.BluRay.x264-GECKOS.sub
\stronger.2017.1080p.bluray.x264-geckos.subs\Stronger.2017.1080p.BluRay.x264-GECKOS\stronger.2017.1080p.bluray.x264-geckos.rar
I was wondering if either the two options below could be possible to have a better fix:
1. Copy any subtitle files that has the same name of the media file aside the media file even if it is found in another directory (after extraction).
2. Unzip any file in a flatten way in the same directory (instead of unzipping in a folder named the same as the zip file) so any sub files would end up aside the media file!

By the way here my workaround in a windows batch file:

Code: Select all

@echo off
SET L=%~1
SET S=%~2
SET N=%~3
SET K=%~4
SET D=%~5

REM Copying subs folder in parent folder so filebot amc script can process subtitle files correctly
IF EXIST "%D%\Subs" (
  ECHO "Copying *.rar found in Subs folder"
  copy %D%\Subs\*.rar %D%
) ELSE (
  ECHO Subs not found
)

filebot -script fn:amc --output "E:/Users/plum/Media" --action copy --conflict auto -non-strict --log-file "E:/Users/plum/Media/amc.log" -r --def unsorted=y plex=127.0.0.1:XXXXXXXXX clean=y extractFolder="E:/Users/plum/Downloads/torrent/ZipExtractions" "ut_label=%L%" "ut_state=%S%" "ut_title=%N%" "ut_kind=%K%" "ut_dir=%D%"

Let me know if you have better idea to deal with this!
Thanks
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: AMC Script is not copying extracted subtitles?

Post by rednoah »

1.
Subtitles are tricky, because there's a lot of variety in (bad) naming. Sometimes it's easy to match them to their corresponding video files, sometimes not. The amc script specifically has only very limited support for importing existing subtitles (or existing artwork, companion files, etc). The "orphaned subtitle file" error message basically means that the subtitle file can't be easily / reliably matched to the corresponding video file.

The "orphaned subtitle file" problem is fairly common, but in almost every individual case, it would require a different solution tailored to one specific use case, and I don't intend to blow up the amc script with hundreds of lines of video/subtitle file matching logic.


2.
Preserving the file structure in the archive is often critical to getting the correct match, so FileBot does not flatten the file structure inside the archive. Improvements for subtitle processing must not inadvertently / potentially interfere with movie / episode matching.

:idea: One idea would be to flatten only archives that contain only subtitles. That might be an elegant solution, but I'm not sure if that would actually even solve your specific use case.
:idea: Please read the FAQ and How to Request Help.
ParaMigi
Posts: 2
Joined: 19 Jul 2016, 00:45

Re: AMC Script is not copying extracted subtitles?

Post by ParaMigi »

If it's of any use, I just had the same problem with there being a \Subs folder in the folder of the movie and they were ignored as orphaned subtitles. A problem, however, is that in this \Subs folder, the subs were named "2_eng.srt" and "3_eng.srt" etc. So maybe there is a way to check for a \Subs folder in the same directory as the movie file? And then any .srt (or .sub or whatever) in the \Subs folder should be accepted?

Hope that's of any use... I understand if it is not possible to do this of course, and since the script usually downloads correct subtitles anyway I'm not one to complain. Just thought I'd put in my two cents.
abescalamis
Posts: 30
Joined: 26 Jan 2018, 04:10

Re: AMC Script is not copying extracted subtitles?

Post by abescalamis »

The solution I found is to name the .srt to match the video file before you run the AMC script, I will look for a way to do it automatically.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: AMC Script is not copying extracted subtitles?

Post by rednoah »

This post might be a good start for a pre-processing script for subtitles:
viewtopic.php?f=4&t=5948&p=34106#p34106
:idea: Please read the FAQ and How to Request Help.
Post Reply