1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05:00

Fix for DownloadStation issues.

Added season and episode formatting options for XEM scene numbering.
This commit is contained in:
echel0n 2014-04-26 14:14:38 -07:00
parent 4f049f4e7e
commit abc6841eb3
2 changed files with 55 additions and 42 deletions

View File

@ -328,6 +328,16 @@
<td>%0S</td>
<td>02</td>
</tr>
<tr class="even">
<td class="align-right"><b>XEM Season Number:</b></td>
<td>%XMS</td>
<td>2</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>%0XMS</td>
<td>02</td>
</tr>
<tr class="even">
<td class="align-right"><b>Episode Number:</b></td>
<td>%E</td>
@ -338,6 +348,16 @@
<td>%0E</td>
<td>03</td>
</tr>
<tr class="even">
<td class="align-right"><b>XEM Episode Number:</b></td>
<td>%XME</td>
<td>3</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>%0XME</td>
<td>03</td>
</tr>
<tr class="even">
<td class="align-right"><b>Episode Name:</b></td>
<td>%EN</td>

View File

@ -1,4 +1,6 @@
# Authors: Mr_Orange & Jens Timmerman <jens.timmerman@gmail.com>
# Authors:
# Pedro Jose Pereira Vieito <pvieito@gmail.com> (Twitter: @pvieito)
#
# URL: https://github.com/mr-orange/Sick-Beard
#
# This file is part of Sick Beard.
@ -15,12 +17,12 @@
#
# You should have received a copy of the GNU General Public License
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
#
# Uses the Synology Download Station API: http://download.synology.com/download/other/Synology_Download_Station_Official_API_V3.pdf.
import sickbeard
from sickbeard import logger
from sickbeard.clients.generic import GenericClient
class DownloadStationAPI(GenericClient):
def __init__(self, host=None, username=None, password=None):
@ -31,48 +33,39 @@ class DownloadStationAPI(GenericClient):
def _get_auth(self):
params = {'api': 'SYNO.API.Auth',
'version': '2',
'method': 'login',
'account': self.username,
'passwd': self.password,
'session': 'SickBeard',
'format': 'sid',
}
auth_url = self.host + 'webapi/auth.cgi?api=SYNO.API.Auth&version=2&method=login&account=' + self.username + '&passwd=' + self.password + '&session=DownloadStation&format=sid'
self.response = self.session.get(self.host + 'webapi/auth.cgi', params=params)
if not self.response.json["success"]:
try:
self.response = self.session.get(auth_url)
self.auth = self.response.json()['data']['sid']
except:
return None
self.auth = self.response.json["data"]["sid"]
return self.auth
def _add_torrent_uri(self, result):
params = {'api': 'SYNO.DownloadStation.Task',
'version': '1',
'method': 'create',
'_sid': self.auth,
'uri': result.url,
}
data = {'api':'SYNO.DownloadStation.Task',
'version':'1', 'method':'create',
'session':'DownloadStation',
'_sid':self.auth,
'uri':result.url
}
self._request(method='post', data=data)
self._request(method='get', params=params)
return self.response.json["success"]
return self.response.json()['success']
def _add_torrent_file(self, result):
params = {'api': 'SYNO.DownloadStation.Task',
'version': '1',
'method': 'create',
'_sid': self.auth,
'file': 'tv.torrent',
}
data = {'api':'SYNO.DownloadStation.Task',
'version':'1',
'method':'create',
'session':'DownloadStation',
'_sid':self.auth
}
files = {'file':(result.name + '.torrent', result.content)}
self._request(method='post', data=data, files=files)
self._request(method='get', params=params, files={'file': result.content})
return self.response.json["success"]
return self.response.json()['success']
api = DownloadStationAPI()