Added torrent support for Synology downloader. #1791
Conversation
Thanks for the PR, but I can't add this if it doesn't allow the pushing of torrents. |
Ok, will try harder to make the file upload work. |
I can't help you out but maybe @clinton-hall can, he is always bragging about all his NAS systems ;) |
Lol. The only problem there is that I don't have Synology. @saxicek can you provide details of the errors encountered when you tried to push the file? |
Well Synology Download Station uses Transmission to download torrents which may be fall back variant to make it work. Other option is that it has undocumented API used for their own web frontend (it seems that Synodroid DS is using it). And finally there is official API from Synology for Download Station but it does not provide all the functionlaity and is not documented well. The existing Synology provider is using the official API. So I tried to extend it to send file via Python-requests but it failed with HTTP 200 and {u'success': False, u'error': {u'code': 101}} -- that should mean invalid parameters. But no more details, no example so I have to experiment. :-/ |
Create Parameter uri file username Optional. Login username Optional. Login password unzip_password Optional. Password for unzipping download tasks Example: POST /webapi/DownloadStation/task.cgi Limitations All from page 24 and 29 of http://download.synology.com/download/ds/userguide/Synology_Download_Station_Official_API.pdf Does any of this help? It looks like file upload is possible (and documented) |
Well yes, it is documented, but I just cannot make it work. I tried both approaches from file upload limitaions, below is the a) variant: args = {'api':'SYNO.DownloadStation.Task', 'version':1, 'method':'create', '_sid':self.sid}
url = self.download_url + '?' + urllib.urlencode(args)
files = {'file': (data['name'] + '.' + data['type'], filedata)}
r = requests.post(url, files=files)
response = json.loads(r.text) But it returns the error HTTP 200 and {u'success': False, u'error': {u'code': 101}}. Not really sure what is wrong. :-/ |
Could you try using the urlopen functions provided by the Downloader class? args = {'api':'SYNO.DownloadStation.Task', 'version':1, 'method':'create', '_sid':self.sid}
url = self.download_url + '?' + urllib.urlencode(args)
files = {'file': (data['name'] + '.' + data['type'], filedata)}
response = self.getJsonData(url, params = files, cache_timeout = 1, multipart = True) |
Tried but same result. :-( Will try the frontend API since there I can at least track successful requests. |
Did you zip the data? |
I made it working using requests, but the issue is that current bundled version is too old (0.14.1). Is it possible to update it? I tested it with the latest - 1.2.3. args = {'api': 'SYNO.DownloadStation.Task',
'version': '1',
'method': 'create',
'_sid': self.sid}
files = {'file': (data['name']+'.'+data['type'], filedata)}
resp_raw = requests.post(self.download_url, data=args, files=files)
response = json.loads(resp_raw.text) |
Yeah, just update the lib folder. |
…orrent files passed directly by CouchPotato.
Commited version that works for both magnets (tested on PirateBay) and torrents (tested on TorrentShack). Can you please merge? There is one more thing - Synology DownloadStation also supports nzb and it would be very easy to add it (same method like for torrents). But you can also have SABnzbd installed on Synology. And if user prefers DownloadStation for torrents and SABnzbd for nzb, it is not possible to configure it when Synology has nzb support enabled. Any idea? |
Maybe duplicate the downloader and rename it for NZB? You could simply inherit the current Syno downloader and replace the supported protocols by NZB? |
Or a new option in settings, downloaders, Synology |
I would prefer solution as suggested by @clinton-hall but that would require to implement such support in CouchPotatoServer. |
Have a look at the blackhole downloader, that implements the same thing. |
Merged. Can't test this, so I trust you on this ;) |
I am asking probably a stupid question but where was it merged? I added nzb support as discussed above but when trying to create pull request to master it is trying to add also revisions where I added the torrent support. Don't want to cause you issues with duplicities... Thanks. |
Merged in develop branch. |
Added support for torrents to Synology downloader.
It uses remote torrent URL so the URL should point directly to torrent without the need for authentication. I also tried to push the torrent file downloaded by CouchPotato directly to Synology, but the Synology API returns errors and documentation does not provide any hints on possible error cause. File upload is tricky. :-(