Fix: Searching in OpenSubtitles.org and Napisy24 not working for files larger then 2GiB #178
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Due to integer overflow, searching for subtitles in OpenSubtitles.org and Napisy24 never yielded any results for files larger the 2GiB.
The exact problem is that a signed, 32-bit integer is used when calculating offset in a video file from which to read bytes that feed checksum calculation. This results in wrong checksum if size of the file exceeds ~2GiB.
There is also another problem specific to OpenSubtitles.org - the overall size of the video file is being send to OpenSubtitles.org as a 32-bit signed integer which causes overflow and a wrong number being send.
This pull request fixes the issue by using 64-bit integers when calculating checksum and sending video file size to OpenSubtitles.org as a string.
I tested the bug and the fix on these files (replace [COLON] with a colon):
magnet[COLON]?xt=urn:btih:408ceb0d4ed6a2fb96d494f63c6650087dd0759f&dn=Homeland.S03.1080p.AMZN.WEBRip.DDP5.1.x265-SiGMA%5brartv%5d&tr=udp%3a%2f%2ftracker.coppersurfer.tkg%3a6969%2fannounce&tr=http%3a%2f%2ftracker.trackerfix.com%3a80%2fannounce&tr=udp%3a%2f%2fexplodie.org%3a6969%2fannounce&tr=udp%3a%2f%2ftracker.opentrackr.org%3a1337%2fannounce&tr=udp%3a%2f%2ftracker.internetwarriors.net%3a1337%2fannounce&tr=udp%3a%2f%2f9.rarbg.me%3a2710&tr=udp%3a%2f%2f9.rarbg.to%3a2710&tr=udp%3a%2f%2ftracker.leechers-paradise.org%3a6969%2fannounce&tr=udp%3a%2f%2fopen.demonii.com%3a1337%2fannounce&tr=udp%3a%2f%2ftracker.coppersurfer.tk%3a6969%2fannounce&tr=udp%3a%2f%2ftracker.pirateparty.gr%3a6969%2fannounce&tr=udp%3a%2f%2ftracker.cyberia.is%3a6969%2fannounce&tr=udp%3a%2f%2fopen.demonii.si%3a1337%2fannounce&tr=udp%3a%2f%2fopen.stealth.si%2fannounce&tr=udp%3a%2f%2fexodus.desync.com%3a6969%2fannounce&tr=http%3a%2f%2fexplodie.org%3a6969%2fannounce&tr=https%3a%2f%2ftracker.cyber-hub.net%2fannounce&tr=udp%3a%2f%2f9.rarbg.me%3a2740%2fannounce&tr=udp%3a%2f%2f9.rarbg.to%3a2790%2fannounce
Try English subtitles from OpenSubtitles.org and Polish subtitles from Napisy24 for S03E12. You don't have to download everything, first and last 64KiB of the file is enough (use e.g. qBittorrent to download only the front and the back of a file).
You can also test the checksum calculation on exemplary "DUMMY RAR file" provided by OpenSubtitles.org, get it here:
https://trac.opensubtitles.org/projects/opensubtitles/wiki/HashSourceCodes
NOTE: c++ implementation of the checksum algorithm on the above page is invalid and suffers from the same integer overflow bug.