srrDB / pyrescene

MIT License
56 stars 11 forks source link

Unable to recreate sub files (rar) #14

Closed SnooPac closed 2 months ago

SnooPac commented 2 months ago

Hi. Sorry I'm not sure if this is an 'issue' or a lack of documentation or an inability by me to find the correct documentation or... I'm unable to find any instructions on how to re-create the subtitle rar file.

In the help and the doc and random searches online, it only seems to show the flags I need in order to generate the subtitle srr files, using -v or --vobsub-srr.

However I don't see anything telling me how to go the other way. I have the extracted .sub and .idx files, but can't figure out how to use the sub srr file to generate the rar.

I tried to simply run srr.py on the sub.srr file, but the best it seems to do is generate a languages.diz file. But it won't reconstruct the rar file (properly). I also tried pyrescene.py but can't get close with that.

I can't tell if I'm doing something wrong, or if there's a problem with re-generating subtitle rar files -- maybe it's just not supported? But then why would there be documentation for creating the subtitle srr files if there's no way to reconstruct?

Sorry to bother. And thanks for any help.

itzoke commented 2 months ago

Did you set up the rar dir using preprardir? This is required since subs are compressed.

itzoke commented 2 months ago

http://rescene.wikidot.com/tutorials#toc6 <- did you read this? If not, start there.

SnooPac commented 2 months ago

Did you set up the rar dir using preprardir? This is required since subs are compressed.

Hi. First, thanks for the quick reply. No, I hadn't known I have to do that. I just tried it in Linux, and nothing really happened. I guess I'll need to do it in Windows.

http://rescene.wikidot.com/tutorials#toc6 <- did you read this? If not, start there.

I had seen this page before, in my searches, but I still don't fully understand how this relates to recreating the sub file. Well I guess I get it in general, the rar file I'm trying to reconstruct was compressed, and I need this extra step to get around that. But I still don't see the exact process. Do I do the preprardir first, then somehow use those rar executables after. Anyway, I'll go away and play with it and try. Chances are all the answers are in that tutorial. Thanks for pointing me in the right general direction!

itzoke commented 2 months ago

It works in Linux too... Just grab one of the rar-packs for Linux and use preprardir

itzoke commented 2 months ago

There is a list of packs on http://rescene.wikidot.com/rar-versions

itzoke commented 2 months ago

But I still don't see the exact process. Do I do the preprardir first, then somehow use those rar executables after.

You only need to run preprardir once (or when you add more rar versions). After that you just add -z <path/to/rardir> along with the usual flags used to recreate a rar along with the subs-srr.

If a good rar version is found but crc won't match you'll need to try with different --mt settings.

SnooPac commented 2 months ago

Hi. So I got the Linux files and ran preprardir and created the contents in output directory ~/tmp/rar/test/.

prompt> srr.py -z ~/tmp/rar/test/ subs-myfile.srr

SRR file created with pyReScene Auto 0.7.
Warning: File /path/to/my/file/MYFILE.srr already exists.
Do you wish to continue? (Y/N): y
Re-creating stored file: MYFILE.srr
Re-creating stored file: languages.diz
Re-creating RAR file: subs-myfile.rar
The file does not exist: /path/to/my/file/MYFILE.rar.

It's right, technically. I never had MYFILE.rar. I had myfile.rar (and myfile.r00 and myfile.r01 etc, that were generated from the main MYFILE.srr). Ok, so I tried to copy myfile.rar to MYFILE.rar and ran the same command.

prompt> srr.py -z ~/tmp/rar/test/ subs-myfile.srr

SRR file created with pyReScene Auto 0.7.
Warning: File /path/to/my/file/MYFILE.srr already exists.
Do you wish to continue? (Y/N): y
Re-creating stored file: MYFILE.srr
Warning: File /path/to/my/file/languages.diz already exists.
Do you wish to continue? (Y/N): y
Re-creating stored file: languages.diz
Warning: File /path/to/my/file/subs-myfile.rar already exists.
Do you wish to continue? (Y/N): y
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/rescene/srr.py", line 602, in main
    parser.exit(manage_srr(options, infolder, infiles, working_dir))
  File "/usr/local/lib/python3.10/dist-packages/rescene/srr.py", line 312, in manage_srr
    rescene.reconstruct(infiles[0], in_folder, out_folder, save_paths,
  File "/usr/local/lib/python3.10/dist-packages/rescene/main.py", line 1316, in reconstruct
    src = _locate_file(block, in_folder,
  File "/usr/local/lib/python3.10/dist-packages/rescene/main.py", line 1466, in _locate_file
    raise InvalidFileSize("Data file is not the correct size: %s.\n"
rescene.main.InvalidFileSize: Data file is not the correct size: /path/to/my/file/MYFILE.rar.
Found: 150000000 bytes.
Expected: 5409346 bytes.

Unexpected Error: Data file is not the correct size: /path/to/my/file/MYFILE.rar.
Found: 150000000 bytes.
Expected: 5409346 bytes.
Re-creating RAR file: subs-myfile.rar

Some notes. I get this exact result whether I use the -z option or not. I get this exact result whether I have MYFILE.idx and MYFILE.sub in the folder or not. I would have thought I need these files to regenerate the rar, the same way you need the mkv file to regenerate the rar set for the main file. But it didn't complain that they were missing, or behave differently when they weren't there.

I don't think this is what you mean when you say crc won't match and I need to try different --mt settings. I feel like I'm doing something else major that's wrong :).

Thanks

itzoke commented 2 months ago

The <rls>.subs.srr file usually contains another .srr-file which is used to create the compressed version of the .sub file.

So after extracting all possible .srr files you should have something like this

secret.rls-name.idx
secret.rls-name.srr
secret.rls-name.sub
secret.rls-name.subs.srr

At this point you're ready to start reconstructing the innermost rar file

$ srr.py -z /path/to/preped/rardir secret.rls-name.srr 
/usr/local/bin/srr.py:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  __import__('pkg_resources').run_script('pyReScene==0.7', 'srr.py')
SRR file created with pyReScene Auto 0.5.
Re-creating RAR file: secret.rls-name.rar
Trying to rebuild compressed file secret.rls-name.sub.
Grabbing large enough data piece size for testing.
Trying 2014-12-02 5.20.
Trying 2014-08-27 5.11.
Trying 2014-06-10 5.10.
Trying 2013-12-01 5.01.
Trying 2013-08-22 5.00.
Trying 2012-06-09 4.20.
Good RAR version detected: 2012-06-09 4.20
/path/to/preped/rardir/2012-06-09_rar420 a -m3 -mdG -s- -ds -mt8 -vn -o+ -ep -idcd /tmp/SRR-3v1gmx40/pyReScene_compressed.rar /tmp/srr-test/secret.rls-name.sub
Compressing secret.rls-name.sub...

Evaluation copy. Please register.

Creating archive /tmp/SRR-3v1gmx40/pyReScene_compressed.rar

Adding    /tmp/srr-test/secret.rls-name.sub  OK 

If/When this stage has completed run srr.py secret.rls-name.subs.srr to recreate the final subs.rar (this one is not compressed)

$ srr.py -y secret.rls-name.subs.srr 
/usr/local/bin/srr.py:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  __import__('pkg_resources').run_script('pyReScene==0.7', 'srr.py')
SRR file created with pyReScene Auto 0.5.
Re-creating stored file: secret.rls-name.srr
Re-creating stored file: languages.diz
Re-creating RAR file: secret.rls-name.subs.rar
SnooPac commented 2 months ago

Hi @itzoke.

Sorry for taking so long, but finally had a chance to look at this today. I was able to create the 4 files (idx, srr, sub, subs.srr), but when I tried the command, it told me RAR5 files are not yet supported!.

$ srr.py -z ~/tmp/rar/test secret.rls-name.srr
SRR file created with pyReScene Auto 0.7.
Re-creating RAR file: secret.rls-name.rar
Trying to rebuild compressed file secret.rls-name.sub.
Grabbing large enough data piece size for testing.
Trying 2017-08-11 5.50.
RAR5 files are not yet supported!
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/rescene/srr.py", line 602, in main
    parser.exit(manage_srr(options, infolder, infiles, working_dir))
  File "/usr/local/lib/python3.10/dist-packages/rescene/srr.py", line 312, in manage_srr
    rescene.reconstruct(infiles[0], in_folder, out_folder, save_paths,
  File "/usr/local/lib/python3.10/dist-packages/rescene/main.py", line 1322, in reconstruct
    srcfs = get_rar_data_object(block, blocks, src,
  File "/usr/local/lib/python3.10/dist-packages/rescene/main.py", line 1711, in get_rar_data_object
    compressed_rar_file_factory(block, blocks, src, in_folder, hints,
  File "/usr/local/lib/python3.10/dist-packages/rescene/main.py", line 2023, in compressed_rar_file_factory
    return CompressedRarFile(block, blocks, src,
  File "/usr/local/lib/python3.10/dist-packages/rescene/main.py", line 2148, in __init__
    self.good_rar = self.search_matching_rar_executable(
  File "/usr/local/lib/python3.10/dist-packages/rescene/main.py", line 2397, in search_matching_rar_executable
    if try_rar_executable(rar, args, old):
  File "/usr/local/lib/python3.10/dist-packages/rescene/main.py", line 2327, in try_rar_executable
    with RarStream(out, compressed=True, packed_file_name=pfn) as rs:
  File "/usr/local/lib/python3.10/dist-packages/rescene/rarstream.py", line 76, in __init__
    if not middle and not _check(first_rar):
  File "/usr/local/lib/python3.10/dist-packages/rescene/rarstream.py", line 44, in _check
    rar_reader = rar.RarReader(first_rar)
  File "/usr/local/lib/python3.10/dist-packages/rescene/rar.py", line 1429, in __init__
    raise ValueError("RAR5 files are not yet supported!")
ValueError: RAR5 files are not yet supported!

My ~/tmp/rar/test/ folder does seem to have (only) rar5 executables:

~/tmp/rar/test$ ll
488432 Aug 22  2013 2013-08-22_rar500*
488464 Dec  1  2013 2013-12-01_rar501*
525296 Jun 10  2014 2014-06-10_rar510*
525296 Aug 27  2014 2014-08-27_rar511*
529392 Dec  2  2014 2014-12-02_rar520*
529392 Feb 15  2015 2015-02-15_rar521*
533488 Nov 18  2015 2015-11-18_rar530*
537584 Aug 14  2016 2016-08-14_rar540*
541648 Aug 11  2017 2017-08-11_rar550*

Edit before sending. I tried to manually find a new RAR version not in the pack. I found/generated 2020-03-26_rar590

But that still gave the same error.

Trying 2020-03-26 5.90.
RAR5 files are not yet supported!

Edit2: Found/tried some others (5.91 and 6.24) and got the same error. Also tried 7.01 and got a different (worse?) error.

Am I out of luck?

Thanks regardless for the help.

itzoke commented 2 months ago

Remove any rar versions 5.50 and newer. These default to rar5 which is not supported.

SnooPac commented 2 months ago

Thanks @itzoke You're the best. It worked.

itzoke commented 2 months ago

For info, PR #15 which was merged today should fix the issue with rar5.5+ defaulting to the unsupported rar5 format. So if you're on the master branch you no longer need to remove 5.5 and later versions.