SOLVED - Use autodl-curl-sonarr with bitmetv

Hi, I’m using rtorrent with autodl-irssi towards BitmeTV and it working great. But, I’d rather define the filters in Sonarr than in rtorrent, well basically since that what Sonarr is great at.

I configured the autodl-curl-sonarr script created by @Zymest as mentioned here: Any future plans for IRC support?

The script is working and together with a filter that matches everything it’s sending the torrent urls to Sonarr where Sonar can make the decision. But, since BitmeTV requires cookies for the torrent download it doesn’t work with that particular site.

Can anybody help me update the script to work with BitmeTV? Thanks!

As per usual, as soon as you ask the question you figure out the answer… For anyone else wanting to do this:

Update the autodl-curl-sonarr.sh script to include the bitmetv cookie by adding "–cookie “uid=YOUR_COOKIE_UID;pass=YOUR_COOKIE_PASS” to the curl command

The line should look like this:

/usr/bin/curl -v --cookie “uid=YOUR_UID;pass=YOUR_PASS” -i -H “Accept: application/json” -H “Content-Type: application/json” -H “X-Api-Key: $apiKey” -X POST -d ‘{“title”:"’"$title"’",“downloadUrl”:"’"$downloadUrl"’",“downloadProtocol”:“torrent”,“publishDate”:"’"$date"’"}’ http://localhost:8989/api/release/push

Set up your autodl.cfg (located here: ~/.autodl/autodl.cfg) to include something like this, either in the global [options] header or for specific [filter]s as you see fit (I setup and use a “Match All” filter).

Add “?uid=YOUR_UID&passkey=YOUR_PASSKEY” (without quotes) after “$(TorrentUrl)” to append your login information:

Update the path to the script and YOUR_UID, YOUR_PASSKEY YOUR_SONARR_API_KEY to the values for your system:

upload-type = exec
upload-command = /path/to/autodl-curl-sonarr.sh
upload-args = “$(TorrentName)” “$(TorrentUrl)?uid=YOUR_UID&passkey=YOUR_PASSKEY” YOUR_SONARR_API_KEY

You can set up autodl-irssi filters to simply match everything and let Sonarr decide what it should download based upon your Sonarr configuration.

Seems I spoke a bit too soon… It works from the command line, when I run the shell script and provide the arguments myself, but it doesn’t work when invoked by the filter.

Is it perhaps a permission issue, is the filter running the script as a different user than the one I’m logged in as? When I check by running the command “ps aux” it looks like rtorrent as well as irssi is running as the local user.

I’ve done a chmod 777 on the shell script and placed it in the local user’s home directory, but I can only test once a day for the filter to pick it up which makes it take a bit long to test…

Figured out the problem: after looking at the logs, it seems the cookie information is not being passed when the URL is sent to Deluge, which menas Deluge is redirected to the login page instead of getting the torrent file.

Is there any way to add the cookie information when sending the URL to the download client? I guess it might be different for each client, so maybe it should be possible for Sonarr to fetch the torrent first since the private tracker (bitmetv) is already configured as an indexer, and then send it to the download client?

Sonarr grabs the torrent and then passes it to the client, only in the case of magnets does Sonarr send it to the client to download, but those connect to the swarm so it shouldn’t be an issue.

Thanks for the response! Then it makes a bit more sense; the redirect is actually Sonarr’s HTTP client request to download the torrent that gets redirected (I’ve put the relevant 2 lines in bold below). Is there anyway to use a cookie in the “GET” request? Here is the trace log of the event:

16-8-20 09:34:24.6|Trace|Http|Req: 994 [POST] /api/release/push
16-8-20 09:34:24.6|Info|ReleasePushModule|Release pushed: Dark.Matter.S02E06.720p.HDTV.x264-FLEET - http://www.bitmetv.org/download.php/411917/Dark.Matter.S02E06.720p.HDTV.x264-FLEET.torrent?uid=(removed)&passkey=(removed)
16-8-20 09:34:24.6|Info|DownloadDecisionMaker|Processing 1 releases
16-8-20 09:34:24.6|Trace|DownloadDecisionMaker|Processing release 1/1
16-8-20 09:34:24.6|Debug|Parser|Parsing string 'Dark.Matter.S02E06.720p.HDTV.x264-FLEET’
16-8-20 09:34:24.6|Trace|Parser|^(?.+?)(?:(?:-_\W)+S?(?(?<!\d+)(?:\d{1,2}|\d{4})(?!\d+))(?:[ex]|\W[ex]|){1,2}(?\d{2,3}(?!\d+))(?:(?:-|[ex]|\W[ex]|){1,2}(?\d{2,3}(?!\d+)))*)\W?(?!\)
16-8-20 09:34:24.6|Debug|Parser|Episode Parsed. Dark Matter - S02E06
16-8-20 09:34:24.6|Debug|Parser|Language parsed: English
16-8-20 09:34:24.6|Debug|QualityParser|Trying to parse quality for Dark.Matter.S02E06.720p.HDTV.x264-FLEET
16-8-20 09:34:24.6|Debug|Parser|Quality parsed: HDTV-720p v1
16-8-20 09:34:24.6|Debug|Parser|Release Group parsed: FLEET
16-8-20 09:34:24.6|Debug|AcceptableSizeSpecification|Beginning size check for: Dark.Matter.S02E06.720p.HDTV.x264-FLEET
16-8-20 09:34:24.6|Debug|AcceptableSizeSpecification|Release has unknown size, skipping size check.
16-8-20 09:34:24.6|Debug|LanguageSpecification|Checking if report meets language requirements. English
16-8-20 09:34:24.6|Debug|ReleaseRestrictionsSpecification|Checking if release meets restrictions: Dark.Matter.S02E06.720p.HDTV.x264-FLEET
16-8-20 09:34:24.6|Debug|ReleaseRestrictionsSpecification|[Dark.Matter.S02E06.720p.HDTV.x264-FLEET] No restrictions apply, allowing
16-8-20 09:34:24.6|Debug|QualityAllowedByProfileSpecification|Checking if report meets quality requirements. HDTV-720p v1
16-8-20 09:34:24.6|Debug|MinimumAgeSpecification|Not checking minimum age requirement for non-usenet report
16-8-20 09:34:24.6|Debug|RetentionSpecification|Not checking retention requirement for non-usenet report
16-8-20 09:34:24.6|Debug|DelaySpecification|Profile does not require a waiting period before download for Torrent.
16-8-20 09:34:24.6|Debug|HistorySpecification|Performing history status check on report
16-8-20 09:34:24.6|Debug|HistorySpecification|Checking current status of episode [7646] in history
16-8-20 09:34:24.6|Debug|DownloadDecisionMaker|Release accepted
16-8-20 09:34:24.7|Trace|HttpClient|Req: [GET] http://www.bitmetv.org/download.php/411917/Dark.Matter.S02E06.720p.HDTV.x264-FLEET.torrent?uid=(removed)&passkey=(removed)
16-8-20 09:34:24.7|Trace|ConfigService|Using default config value for ‘proxyenabled’ defaultValue:'False’
16-8-20 09:34:25.4|Trace|HttpClient|Res: [GET] http://www.bitmetv.org/download.php/411917/Dark.Matter.S02E06.720p.HDTV.x264-FLEET.torrent?uid=(removed)&passkey=(removed) 302.Redirect (747 ms)
16-8-20 09:34:25.4|Trace|Transmission|Torrent request is being redirected to: /login.php?returnto=%2Fdownload.php%2F411917%2FDark.Matter.S02E06.720p.HDTV.x264-FLEET.torrent%3Fuid%3D(removed)%26passkey%3D2(removed)
16-8-20 09:34:25.4|Trace|HttpClient|Req: [GET] /login.php?returnto=%2Fdownload.php%2F411917%2FDark.Matter.S02E06.720p.HDTV.x264-FLEET.torrent%3Fuid%3D(removed)%26passkey%3D(removed)
16-8-20 09:34:25.4|Warn|ProcessDownloadDecisions|Couldn’t add report to download queue. Dark.Matter.S02E06.720p.HDTV.x264-FLEET

[v2.0.0.4230] System.InvalidCastException: Specified cast is not valid.
at NzbDrone.Common.Http.Dispatchers.ManagedHttpDispatcher.GetResponse (NzbDrone.Common.Http.HttpRequest request, System.Net.CookieContainer cookies) [0x00000] in M:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Common\Http\Dispatchers\ManagedHttpDispatcher.cs:21
at NzbDrone.Common.Http.Dispatchers.FallbackHttpDispatcher.GetResponse (NzbDrone.Common.Http.HttpRequest request, System.Net.CookieContainer cookies) [0x000cc] in M:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Common\Http\Dispatchers\FallbackHttpDispatcher.cs:58
at NzbDrone.Common.Http.HttpClient.Execute (NzbDrone.Common.Http.HttpRequest request) [0x0007e] in M:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Common\Http\HttpClient.cs:65
at NzbDrone.Common.Http.HttpClient.Get (NzbDrone.Common.Http.HttpRequest request) [0x00007] in M:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Common\Http\HttpClient.cs:188
at NzbDrone.Core.Download.TorrentClientBase1[TSettings].DownloadFromWebUrl (NzbDrone.Core.Parser.Model.RemoteEpisode remoteEpisode, System.String torrentUrl) [0x00024] in M:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\TorrentClientBase.cs:106 at NzbDrone.Core.Download.TorrentClientBase1[TSettings].DownloadFromWebUrl (NzbDrone.Core.Parser.Model.RemoteEpisode remoteEpisode, System.String torrentUrl) [0x00096] in M:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\TorrentClientBase.cs:121
at NzbDrone.Core.Download.TorrentClientBase1[TSettings].Download (NzbDrone.Core.Parser.Model.RemoteEpisode remoteEpisode) [0x000ce] in M:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\TorrentClientBase.cs:90 at NzbDrone.Core.Download.DownloadService.DownloadReport (NzbDrone.Core.Parser.Model.RemoteEpisode remoteEpisode) [0x00171] in M:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\DownloadService.cs:66 at NzbDrone.Core.Download.ProcessDownloadDecisions.ProcessDecisions (System.Collections.Generic.List1 decisions) [0x0014e] in M:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\ProcessDownloadDecisions.cs:74

16-8-20 09:34:25.4|Trace|Http|Res: 994 [POST] /api/release/push: 200.OK (855 ms)
16-8-20 09:34:25.4|Debug|Api|[POST] /api/release/push: 200.OK (855 ms)

I figured it out (I think, this works when I run the command manually); the right format to put in the arguments filter which matches everything is (you can keep the changes in the script as previously described, or remove the added cookie argument since we’re adding the information in the arguments instead):

command: /path/to/script/autodl-curl-sonarr.sh

arguments: “$(TorrentName)” “$(TorrentUrl)?uid=YOUR_UID&passkey=YOUR_PASSKEY:COOKIE:uid=YOUR_UID;pass=YOUR_PASS_FROM_COOKIE” YOUR_SONARR_API_KEY

I can confirm if this is working tomorrow when some shows should have been matched by the autodl-irssi filter and sent to Sonarr. Wouldn’t have cracked it without knowing Sonarr actually fetches the .torrent, so many thanks for that insight!

1 Like

I can confirm that this works like charm; rTorrent sends the IRC announcements to Sonarr via the script, and Sonarr holds the intelligence for which torrents to act on.

This should work for other private trackers as well that use cookies.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.