Repository: pymedusa/Medusa

Issue:
WARNING  SEARCHQUEUE-BACKLOG-328686 :: [d6eb72d] Error: u'The requested API does not exist'
### Before submitting your issue:

Enable debug logging in Medusa settings, reproduce the error (be sure to disable after the bug is fixed)

**Branch/Commit:**

Medusa Info: | Branch: masterCommit: d6eb72d4e1019e5d1286ae6ac1d7e4b318229ebeVersion: v0.2.1Database: 44.9
-- | --
Python Version: | 2.7.13 (default, Dec 18 2016, 21:23:50) [GCC 4.6.4]
SSL Version: | OpenSSL 1.0.2j 26 Sep 2016
OS: | Linux-3.2.40-armv7l-with-glibc2.4
Locale: | en_US.UTF-8


**OS: Synoloy
**What you did: search for a episode
**What happened: this in warning log the whole time: Error: u'The requested API does not exist'
**What you expected: don't see this warning
**Logs:**
```
2018-03-12 22:14:05 DEBUG    SEARCHQUEUE-BACKLOG-328686 :: [d6eb72d] With post data: version=1&api=SYNO.DownloadStation.Task&destination=DOWNLOADSTATION&uri=magnet%3A%3Fxt%3Durn%3Abtih%3Abb1e80b3dc489f1856ac8422c97caaa95871fd09%26dn%3DSeal.Team.S01E06.720p.HDTV.X264-DIMENSION%255Brartv%255D%26tr%3Dhttp%253A%252F%252Ftracker.trackerfix.com%253A80%252Fannounce%26tr%3Dudp%253A%252F%252F9.rarbg.me%253A2710%26tr%3Dudp%253A%252F%252F9.rarbg.to%253A2710%26tr%3Dudp%253A%252F%252Fopen.demonii.com%253A1337%252Fannounce%26tr%3Dudp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2Ftracker.zer0day.to%3A1337%2Fannounce%26tr%3Dudp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce%26tr%3Dhttp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce%26tr%3Dudp%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce%26tr%3Dhttp%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce%26tr%3Dudp%3A%2F%2Fexplodie.org%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2F9.rarbg.com%3A2710%2Fannounce%26tr%3Dhttp%3A%2F%2Fexplodie.org%3A6969%2Fannounce%26tr%3Dhttp%3A%2F%2Ftracker.dler.org%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2Fpublic.popcorn-tracker.org%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2Ftracker.internetwarriors.net%3A1337%2Fannounce%26tr%3Dudp%3A%2F%2Fipv4.tracker.harry.lu%3A80%2Fannounce%26tr%3Dhttp%3A%2F%2Fipv4.tracker.harry.lu%3A80%2Fannounce%26tr%3Dudp%3A%2F%2Fmgtracker.org%3A2710%2Fannounce%26tr%3Dhttp%3A%2F%2Fmgtracker.org%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2Ftracker.mg64.net%3A6969%2Fannounce%26tr%3Dhttp%3A%2F%2Ftracker.mg64.net%3A6881%2Fannounce%26tr%3Dhttp%3A%2F%2Ftorrentsmd.com%3A8080%2Fannounce&session=DownloadStation&method=create
2018-03-12 22:14:05 DEBUG    SEARCHQUEUE-BACKLOG-328686 :: [d6eb72d] User-Agent: Medusa/0.1.23 (Linux; 3.2.40; c035924c-261b-11e8-9fcd-00113230256d)
2018-03-12 22:14:05 DEBUG    SEARCHQUEUE-BACKLOG-328686 :: [d6eb72d] POST URL: http://localhost:5000/webapi/DownloadStation/task.cgi [Status: 200]
2018-03-12 22:14:03 DEBUG    SEARCHQUEUE-BACKLOG-328686 :: [d6eb72d] DownloadStation: Requested a POST connection to http://localhost:5000/webapi/DownloadStation/task.cgi with params: None Data: {u'version': u'1', u'api': u'SYNO.DownloadStation.Task', u'destination': u'DOWNLOADSTATION', u'uri'...
2018-03-12 22:14:03 DEBUG    SEARCHQUEUE-BACKLOG-328686 :: [d6eb72d] User-Agent: Medusa/0.1.23 (Linux; 3.2.40; c035924c-261b-11e8-9fcd-00113230256d)
2018-03-12 22:14:03 DEBUG    SEARCHQUEUE-BACKLOG-328686 :: [d6eb72d] GET URL: http://localhost:5000/webapi/auth.cgi?session=DownloadStation&account=**********&version=2&format=cookie&passwd=**********&api=SYNO.API.Auth&method=login [Status: 200]
2018-03-12 22:14:02 INFO     SEARCHQUEUE-BACKLOG-328686 :: [d6eb72d] Destination is now DOWNLOADSTATION
2018-03-12 22:14:02 WARNING  SEARCHQUEUE-BACKLOG-328686 :: [d6eb72d] Error: u'The requested API does not exist'
2018-03-12 22:14:02 DEBUG    SEARCHQUEUE-BACKLOG-328686 :: [d6eb72d] User-Agent: Medusa/0.1.23 (Linux; 3.2.40; c035924c-261b-11e8-9fcd-00113230256d)
2018-03-12 22:14:02 DEBUG    SEARCHQUEUE-BACKLOG-328686 :: [d6eb72d] GET URL: http://localhost:5000/webapi/DownloadStation/info.cgi?session=DownloadStation&version=2&api=SYNO.DSM.Info&method=getconfig [Status: 200]
2018-03-12 22:14:01 DEBUG    SEARCHQUEUE-BACKLOG-328686 :: [d6eb72d] User-Agent: Medusa/0.1.23 (Linux; 3.2.40; c035924c-261b-11e8-9fcd-00113230256d)
```



Discussion:
any idea pls?
`Error 102: The requested API does not exist` is a `Common Error Code` for Synology Download Station.  It may be because of changes to the DS API that Medusa doesn't support yet.  I would recommend posting information about your Download Station version and configuration so the Medusa devs can look into it.
~~Also from the logs it appears that the failed API endpoint it's trying to access is `auth` then make sure you're not trying to use two-factor authentication since Medusa doesn't support it.~~
Edit: Oops, logs are in reverse order.
It appears the failed endpoint is `info` and if i'm not mistaken its because its passing the API param of `SYNO.DSM.Info` which should be `SYNO.DownloadStation.Info`.
@labrys still getting this error at current Medusa version.

2018-04-27 20:40:58 DEBUG    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] DownloadStation: Response to POST request is {"success":true}
2018-04-27 20:40:58 DEBUG    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] With post data: version=1&api=SYNO.DownloadStation.Task&destination=DOWNLOADSTATION&uri=magnet%3A%3Fxt%3Durn%3Abtih%3A17b3b5926ebafc4b3fbe70182c92935ea7fbe4c5%26dn%3DChicago.Fire.S06E20.1080p.AMZN.WEBRip.DDP5.1.x264-KiNGS%255Brartv%255D%26tr%3Dhttp%253A%252F%252Ftracker.trackerfix.com%253A80%252Fannounce%26tr%3Dudp%253A%252F%252F9.rarbg.me%253A2710%26tr%3Dudp%253A%252F%252F9.rarbg.to%253A2710%26tr%3Dudp%253A%252F%252Fopen.demonii.com%253A1337%252Fannounce%26tr%3Dudp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2Ftracker.zer0day.to%3A1337%2Fannounce%26tr%3Dudp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce%26tr%3Dhttp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce%26tr%3Dudp%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce%26tr%3Dhttp%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce%26tr%3Dudp%3A%2F%2Fexplodie.org%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2F9.rarbg.com%3A2710%2Fannounce%26tr%3Dhttp%3A%2F%2Fexplodie.org%3A6969%2Fannounce%26tr%3Dhttp%3A%2F%2Ftracker.dler.org%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2Fpublic.popcorn-tracker.org%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2Ftracker.internetwarriors.net%3A1337%2Fannounce%26tr%3Dudp%3A%2F%2Fipv4.tracker.harry.lu%3A80%2Fannounce%26tr%3Dhttp%3A%2F%2Fipv4.tracker.harry.lu%3A80%2Fannounce%26tr%3Dudp%3A%2F%2Fmgtracker.org%3A2710%2Fannounce%26tr%3Dhttp%3A%2F%2Fmgtracker.org%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2Ftracker.mg64.net%3A6969%2Fannounce%26tr%3Dhttp%3A%2F%2Ftracker.mg64.net%3A6881%2Fannounce%26tr%3Dhttp%3A%2F%2Ftorrentsmd.com%3A8080%2Fannounce&session=DownloadStation&method=create
2018-04-27 20:40:58 DEBUG    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] User-Agent: Medusa/0.2.2 (Linux; 3.2.40; 98464a59-4a43-11e8-b430-00113230256d)
2018-04-27 20:40:58 DEBUG    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] POST URL: http://localhost:5000/webapi/DownloadStation/task.cgi [Status: 200]
2018-04-27 20:40:54 DEBUG    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] DownloadStation: Requested a POST connection to http://localhost:5000/webapi/DownloadStation/task.cgi with params: None Data: {u'version': u'1', u'api': u'SYNO.DownloadStation.Task', u'destination': u'DOWNLOADSTATION', u'uri'...
2018-04-27 20:40:54 DEBUG    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] User-Agent: Medusa/0.2.2 (Linux; 3.2.40; 98464a59-4a43-11e8-b430-00113230256d)
2018-04-27 20:40:54 DEBUG    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] GET URL: http://localhost:5000/webapi/auth.cgi?session=DownloadStation&account=**********&version=2&format=cookie&passwd=**********&api=SYNO.API.Auth&method=login [Status: 200]
2018-04-27 20:40:53 INFO     SEARCHQUEUE-DAILY-SEARCH :: [77b2091] Destination is now DOWNLOADSTATION
2018-04-27 20:40:53 WARNING  SEARCHQUEUE-DAILY-SEARCH :: [77b2091] Error: u'The requested API does not exist'
2018-04-27 20:40:53 DEBUG    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] User-Agent: Medusa/0.2.2 (Linux; 3.2.40; 98464a59-4a43-11e8-b430-00113230256d)
2018-04-27 20:40:53 DEBUG    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] GET URL: http://localhost:5000/webapi/DownloadStation/info.cgi?session=DownloadStation&version=2&api=SYNO.DSM.Info&method=getconfig [Status: 200]
2018-04-27 20:40:52 DEBUG    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] User-Agent: Medusa/0.2.2 (Linux; 3.2.40; 98464a59-4a43-11e8-b430-00113230256d)
2018-04-27 20:40:52 DEBUG    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] GET URL: http://localhost:5000/webapi/entry.cgi?session=DownloadStation&api=SYNO.DSM.Info&version=2&method=getinfo [Status: 200]
2018-04-27 20:40:52 DEBUG    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] User-Agent: Medusa/0.2.2 (Linux; 3.2.40; 98464a59-4a43-11e8-b430-00113230256d)
2018-04-27 20:40:52 DEBUG    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] GET URL: http://localhost:5000/webapi/auth.cgi?session=DownloadStation&account=**********&version=2&format=cookie&passwd=**********&api=SYNO.API.Auth&method=login [Status: 200]
2018-04-27 20:40:50 DEBUG    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] Calling DownloadStation Client

downloadstation version: 3.8.8-3501
@ward0 I haven't been a dev for medusa since well before I responded to your post.  If you want this fixed you need to talk to one of the devs such as @medariox @p0psicles or @sharkykh and point them to my comment for the fix.  You could also make the change yourself and even submit a PR for it.  I don't have a Syno to test it either, my comment was from reading the docs.

> It appears the failed endpoint is info and if i'm not mistaken its because its passing the API param of SYNO.DSM.Info which should be SYNO.DownloadStation.Info.
@ward0 Try replacing https://github.com/pymedusa/Medusa/blob/master/medusa/clients/torrent/download_station_client.py#L162 with `'api': 'SYNO.DownloadStation.Info',` and restart Medusa. If it works we will push it to develop.
@medariox @labrys , I will test tonight and provide feedback later on.
@medariox @labrys , i edited the line, i did a shutdown of medusa and started a download:

```
2018-04-30 21:39:14 DEBUG    SEARCHQUEUE-FORCED-290853 :: [77b2091] DownloadStation: Response to POST request is {"success":true}
2018-04-30 21:39:14 DEBUG    SEARCHQUEUE-FORCED-290853 :: [77b2091] With post data: version=1&api=SYNO.DownloadStation.Task&destination=DOWNLOADSTATION&uri=magnet%3A%3Fxt%3Durn%3Abtih%3Aada3aad4fb77439609ff19562fedaaf1f9908d31%26dn%3DFear.the.Walking.Dead.S04E03.1080p.WEB.H264-DEFLATE%255Brartv%255D%26tr%3Dhttp%253A%252F%252Ftracker.trackerfix.com%253A80%252Fannounce%26tr%3Dudp%253A%252F%252F9.rarbg.me%253A2710%26tr%3Dudp%253A%252F%252F9.rarbg.to%253A2710%26tr%3Dudp%253A%252F%252Fopen.demonii.com%253A1337%252Fannounce%26tr%3Dudp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2Ftracker.zer0day.to%3A1337%2Fannounce%26tr%3Dudp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce%26tr%3Dhttp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce%26tr%3Dudp%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce%26tr%3Dhttp%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce%26tr%3Dudp%3A%2F%2Fexplodie.org%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2F9.rarbg.com%3A2710%2Fannounce%26tr%3Dhttp%3A%2F%2Fexplodie.org%3A6969%2Fannounce%26tr%3Dhttp%3A%2F%2Ftracker.dler.org%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2Fpublic.popcorn-tracker.org%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2Ftracker.internetwarriors.net%3A1337%2Fannounce%26tr%3Dudp%3A%2F%2Fipv4.tracker.harry.lu%3A80%2Fannounce%26tr%3Dhttp%3A%2F%2Fipv4.tracker.harry.lu%3A80%2Fannounce%26tr%3Dudp%3A%2F%2Fmgtracker.org%3A2710%2Fannounce%26tr%3Dhttp%3A%2F%2Fmgtracker.org%3A6969%2Fannounce%26tr%3Dudp%3A%2F%2Ftracker.mg64.net%3A6969%2Fannounce%26tr%3Dhttp%3A%2F%2Ftracker.mg64.net%3A6881%2Fannounce%26tr%3Dhttp%3A%2F%2Ftorrentsmd.com%3A8080%2Fannounce&session=DownloadStation&method=create
2018-04-30 21:39:14 DEBUG    SEARCHQUEUE-FORCED-290853 :: [77b2091] User-Agent: Medusa/0.2.2 (Linux; 3.2.40; 9085554c-4cad-11e8-a65e-00113230256d)
2018-04-30 21:39:14 DEBUG    SEARCHQUEUE-FORCED-290853 :: [77b2091] POST URL: http://localhost:5000/webapi/DownloadStation/task.cgi [Status: 200]
2018-04-30 21:39:10 DEBUG    SEARCHQUEUE-FORCED-290853 :: [77b2091] DownloadStation: Requested a POST connection to http://localhost:5000/webapi/DownloadStation/task.cgi with params: None Data: {u'version': u'1', u'api': u'SYNO.DownloadStation.Task', u'destination': u'DOWNLOADSTATION', u'uri'...
2018-04-30 21:39:10 DEBUG    SEARCHQUEUE-FORCED-290853 :: [77b2091] User-Agent: Medusa/0.2.2 (Linux; 3.2.40; 9085554c-4cad-11e8-a65e-00113230256d)
2018-04-30 21:39:10 DEBUG    SEARCHQUEUE-FORCED-290853 :: [77b2091] GET URL: http://localhost:5000/webapi/auth.cgi?session=DownloadStation&account=**********&version=2&format=cookie&passwd=**********&api=SYNO.API.Auth&method=login [Status: 200]
2018-04-30 21:39:09 INFO     SEARCHQUEUE-FORCED-290853 :: [77b2091] Destination is now DOWNLOADSTATION
2018-04-30 21:39:09 WARNING  SEARCHQUEUE-FORCED-290853 :: [77b2091] Error: u'The requested API does not exist'
2018-04-30 21:39:09 DEBUG    SEARCHQUEUE-FORCED-290853 :: [77b2091] User-Agent: Medusa/0.2.2 (Linux; 3.2.40; 9085554c-4cad-11e8-a65e-00113230256d)
2018-04-30 21:39:09 DEBUG    SEARCHQUEUE-FORCED-290853 :: [77b2091] GET URL: http://localhost:5000/webapi/entry.cgi?session=DownloadStation&api=SYNO.DownloadStation.Info&version=2&method=getinfo [Status: 200]
2018-04-30 21:39:09 DEBUG    SEARCHQUEUE-FORCED-290853 :: [77b2091] User-Agent: Medusa/0.2.2 (Linux; 3.2.40; 9085554c-4cad-11e8-a65e-00113230256d)
2018-04-30 21:39:09 DEBUG    SEARCHQUEUE-FORCED-290853 :: [77b2091] GET URL: http://localhost:5000/webapi/auth.cgi?session=DownloadStation&account=**********&version=2&format=cookie&passwd=**********&api=SYNO.API.Auth&method=login [Status: 200]
2018-04-30 21:39:08 DEBUG    SEARCHQUEUE-FORCED-290853 :: [77b2091] Calling DownloadStation Client

the date modified of the file is changed and this is changed inside the file:

        params = {
            'api': 'SYNO.DownloadStation.Info',
            'version': 2,
            'method': 'getinfo',
            'session': 'DownloadStation',
        }

```
@ward0 Instead of the `dsminfo` URL it should be using the `info` url.  The `dsminfo` URL is no longer used and can be deleted.

So change [L169](https://github.com/pymedusa/Medusa/blob/master/medusa/clients/torrent/download_station_client.py#L169) from 
`self.response = self.session.get(self.urls['dsminfo'], params=params, verify=False, timeout=120)`
to
 `self.response = self.session.get(self.urls['info'], params=params, verify=False, timeout=120)`

and delete [L47](https://github.com/pymedusa/Medusa/blob/master/medusa/clients/torrent/download_station_client.py#L47)
`'dsminfo': urljoin(self.host, '/webapi/entry.cgi'),`
@labrys  changed all the things you said, will provide feedback when download started :)
@labrys your fix is OK! Thx, please release to dev, master.

Resolving patch:
diff --git a/medusa/clients/torrent/download_station_client.py b/medusa/clients/torrent/download_station_client.py
--- a/medusa/clients/torrent/download_station_client.py
+++ b/medusa/clients/torrent/download_station_client.py
@@ -44,7 +44,6 @@ def __init__(self, host=None, username=None, password=None):
             'login': urljoin(self.host, 'webapi/auth.cgi'),
             'task': urljoin(self.host, 'webapi/DownloadStation/task.cgi'),
             'info': urljoin(self.host, '/webapi/DownloadStation/info.cgi'),
-            'dsminfo': urljoin(self.host, '/webapi/entry.cgi'),
         }
 
         self.url = self.urls['task']
@@ -159,14 +158,14 @@ def _check_destination(self):
             return True
 
         params = {
-            'api': 'SYNO.DSM.Info',
+            'api': 'SYNO.DownloadStation.Info',
             'version': 2,
             'method': 'getinfo',
             'session': 'DownloadStation',
         }
 
         try:
-            self.response = self.session.get(self.urls['dsminfo'], params=params, verify=False, timeout=120)
+            self.response = self.session.get(self.urls['info'], params=params, verify=False, timeout=120)
             self.response.raise_for_status()
         except RequestException as error:
             handle_requests_exception(error)


Test patch: