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>%0S</td>
<td>02</td> <td>02</td>
</tr> </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"> <tr class="even">
<td class="align-right"><b>Episode Number:</b></td> <td class="align-right"><b>Episode Number:</b></td>
<td>%E</td> <td>%E</td>
@ -338,6 +348,16 @@
<td>%0E</td> <td>%0E</td>
<td>03</td> <td>03</td>
</tr> </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"> <tr class="even">
<td class="align-right"><b>Episode Name:</b></td> <td class="align-right"><b>Episode Name:</b></td>
<td>%EN</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 # URL: https://github.com/mr-orange/Sick-Beard
# #
# This file is part of Sick Beard. # This file is part of Sick Beard.
@ -15,64 +17,55 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>. # 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 import sickbeard
from sickbeard import logger
from sickbeard.clients.generic import GenericClient from sickbeard.clients.generic import GenericClient
class DownloadStationAPI(GenericClient): class DownloadStationAPI(GenericClient):
def __init__(self, host=None, username=None, password=None): def __init__(self, host=None, username=None, password=None):
super(DownloadStationAPI, self).__init__('DownloadStation', host, username, password) super(DownloadStationAPI, self).__init__('DownloadStation', host, username, password)
self.url = self.host + 'webapi/DownloadStation/task.cgi' self.url = self.host + 'webapi/DownloadStation/task.cgi'
def _get_auth(self): def _get_auth(self):
params = {'api': 'SYNO.API.Auth',
'version': '2',
'method': 'login',
'account': self.username,
'passwd': self.password,
'session': 'SickBeard',
'format': 'sid',
}
self.response = self.session.get(self.host + 'webapi/auth.cgi', params=params) 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'
if not self.response.json["success"]: try:
self.response = self.session.get(auth_url)
self.auth = self.response.json()['data']['sid']
except:
return None return None
self.auth = self.response.json["data"]["sid"]
return self.auth return self.auth
def _add_torrent_uri(self, result): def _add_torrent_uri(self, result):
params = {'api': 'SYNO.DownloadStation.Task', data = {'api':'SYNO.DownloadStation.Task',
'version': '1', 'version':'1', 'method':'create',
'method': 'create', 'session':'DownloadStation',
'_sid': self.auth, '_sid':self.auth,
'uri': result.url, '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): def _add_torrent_file(self, result):
params = {'api': 'SYNO.DownloadStation.Task', data = {'api':'SYNO.DownloadStation.Task',
'version': '1', 'version':'1',
'method': 'create', 'method':'create',
'_sid': self.auth, 'session':'DownloadStation',
'file': 'tv.torrent', '_sid':self.auth
} }
files = {'file':(result.name + '.torrent', result.content)}
self._request(method='get', params=params, files={'file': result.content}) self._request(method='post', data=data, files=files)
return self.response.json["success"] return self.response.json()['success']
api = DownloadStationAPI() api = DownloadStationAPI()