Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CouchPotatoServer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
CouchPotatoServer
Commits
618845a0
Commit
618845a0
authored
Nov 30, 2012
by
Ruud
Browse files
Options
Downloads
Patches
Plain Diff
Code formatting
parent
3aabcbf8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
couchpotato/core/downloaders/synology/main.py
+15
-15
15 additions, 15 deletions
couchpotato/core/downloaders/synology/main.py
with
15 additions
and
15 deletions
couchpotato/core/downloaders/synology/main.py
+
15
−
15
View file @
618845a0
...
@@ -3,9 +3,9 @@ from couchpotato.core.helpers.encoding import isInt
...
@@ -3,9 +3,9 @@ from couchpotato.core.helpers.encoding import isInt
from
couchpotato.core.logger
import
CPLog
from
couchpotato.core.logger
import
CPLog
import
httplib
import
httplib
import
json
import
json
import
urllib2
import
urllib
import
urllib
import
urllib2
log
=
CPLog
(
__name__
)
log
=
CPLog
(
__name__
)
...
@@ -35,35 +35,35 @@ class Synology(Downloader):
...
@@ -35,35 +35,35 @@ class Synology(Downloader):
# Send request to Transmission
# Send request to Transmission
srpc
=
SynologyRPC
(
host
[
0
],
host
[
1
],
self
.
conf
(
'
username
'
),
self
.
conf
(
'
password
'
))
srpc
=
SynologyRPC
(
host
[
0
],
host
[
1
],
self
.
conf
(
'
username
'
),
self
.
conf
(
'
password
'
))
remote_torrent
=
srpc
.
add_torrent_uri
(
data
.
get
(
'
url
'
))
remote_torrent
=
srpc
.
add_torrent_uri
(
data
.
get
(
'
url
'
))
log
.
info
(
"
Response: %s
"
,
remote_torrent
)
log
.
info
(
'
Response: %s
'
,
remote_torrent
)
return
remote_torrent
[
'
success
'
]
return
remote_torrent
[
'
success
'
]
except
Exception
,
err
:
except
Exception
,
err
:
log
.
error
(
"
Exception while adding torrent: %s
"
,
err
)
log
.
error
(
'
Exception while adding torrent: %s
'
,
err
)
return
False
return
False
class
SynologyRPC
(
object
):
class
SynologyRPC
(
object
):
"""
SynologyRPC lite library
"""
'''
SynologyRPC lite library
'''
def
__init__
(
self
,
host
=
'
localhost
'
,
port
=
5000
,
username
=
None
,
password
=
None
):
def
__init__
(
self
,
host
=
'
localhost
'
,
port
=
5000
,
username
=
None
,
password
=
None
):
super
(
SynologyRPC
,
self
).
__init__
()
super
(
SynologyRPC
,
self
).
__init__
()
self
.
DLurl
=
'
http://
'
+
host
+
'
:
'
+
str
(
port
)
+
'
/webapi/DownloadStation/task.cgi
'
self
.
download_url
=
'
http://%s:%s
/webapi/DownloadStation/task.cgi
'
%
(
host
,
port
)
self
.
A
uthurl
=
'
http://
'
+
host
+
'
:
'
+
str
(
port
)
+
'
/webapi/auth.cgi
'
self
.
a
uth
_
url
=
'
http://
%s:%s
/webapi/auth.cgi
'
%
(
host
,
port
)
self
.
username
=
username
self
.
username
=
username
self
.
password
=
password
self
.
password
=
password
self
.
session_name
=
"
DownloadStation
"
self
.
session_name
=
'
DownloadStation
'
def
_login
(
self
):
def
_login
(
self
):
if
self
.
username
and
self
.
password
:
if
self
.
username
and
self
.
password
:
args
=
{
'
api
'
:
'
SYNO.API.Auth
'
,
'
account
'
:
self
.
username
,
'
passwd
'
:
self
.
password
,
'
version
'
:
2
,
args
=
{
'
api
'
:
'
SYNO.API.Auth
'
,
'
account
'
:
self
.
username
,
'
passwd
'
:
self
.
password
,
'
version
'
:
2
,
'
method
'
:
'
login
'
,
'
session
'
:
self
.
session_name
,
'
format
'
:
'
sid
'
}
'
method
'
:
'
login
'
,
'
session
'
:
self
.
session_name
,
'
format
'
:
'
sid
'
}
response
=
self
.
_req
(
self
.
A
uthurl
,
args
)
response
=
self
.
_req
(
self
.
a
uth
_
url
,
args
)
if
response
[
'
success
'
]
==
True
:
if
response
[
'
success
'
]
==
True
:
self
.
sid
=
response
[
'
data
'
][
'
sid
'
]
self
.
sid
=
response
[
'
data
'
][
'
sid
'
]
log
.
debug
(
"
Sid=%s
"
,
self
.
sid
)
log
.
debug
(
'
Sid=%s
'
,
self
.
sid
)
return
response
return
response
elif
self
.
username
or
self
.
password
:
elif
self
.
username
or
self
.
password
:
log
.
error
(
'
User or password missing, not using authentication.
'
)
log
.
error
(
'
User or password missing, not using authentication.
'
)
...
@@ -71,7 +71,7 @@ class SynologyRPC(object):
...
@@ -71,7 +71,7 @@ class SynologyRPC(object):
def
_logout
(
self
):
def
_logout
(
self
):
args
=
{
'
api
'
:
'
SYNO.API.Auth
'
,
'
version
'
:
1
,
'
method
'
:
'
logout
'
,
'
session
'
:
self
.
session_name
,
'
_sid
'
:
self
.
sid
}
args
=
{
'
api
'
:
'
SYNO.API.Auth
'
,
'
version
'
:
1
,
'
method
'
:
'
logout
'
,
'
session
'
:
self
.
session_name
,
'
_sid
'
:
self
.
sid
}
return
self
.
_req
(
self
.
A
uthurl
,
args
)
return
self
.
_req
(
self
.
a
uth
_
url
,
args
)
def
_req
(
self
,
url
,
args
):
def
_req
(
self
,
url
,
args
):
req_url
=
url
+
'
?
'
+
urllib
.
urlencode
(
args
)
req_url
=
url
+
'
?
'
+
urllib
.
urlencode
(
args
)
...
@@ -92,17 +92,17 @@ class SynologyRPC(object):
...
@@ -92,17 +92,17 @@ class SynologyRPC(object):
return
False
return
False
def
add_torrent_uri
(
self
,
torrent
):
def
add_torrent_uri
(
self
,
torrent
):
log
.
info
(
"
Adding torrent URL %s
"
,
torrent
)
log
.
info
(
'
Adding torrent URL %s
'
,
torrent
)
response
=
{}
response
=
{}
# login
# login
login
=
self
.
_login
()
login
=
self
.
_login
()
if
len
(
login
)
>
0
and
login
[
'
success
'
]
==
True
:
if
len
(
login
)
>
0
and
login
[
'
success
'
]
==
True
:
log
.
info
(
"
Login success, adding torrent
"
)
log
.
info
(
'
Login success, adding torrent
'
)
args
=
{
'
api
'
:
'
SYNO.DownloadStation.Task
'
,
'
version
'
:
1
,
'
method
'
:
'
create
'
,
'
uri
'
:
torrent
,
'
_sid
'
:
self
.
sid
}
args
=
{
'
api
'
:
'
SYNO.DownloadStation.Task
'
,
'
version
'
:
1
,
'
method
'
:
'
create
'
,
'
uri
'
:
torrent
,
'
_sid
'
:
self
.
sid
}
response
=
self
.
_req
(
self
.
DL
url
,
args
)
response
=
self
.
_req
(
self
.
download_
url
,
args
)
self
.
_logout
()
self
.
_logout
()
else
:
else
:
log
.
error
(
"
Couldn
'
t login to Synology, %s
"
,
login
)
log
.
error
(
'
Couldn
\
'
t login to Synology, %s
'
,
login
)
return
response
return
response
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment