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
afea12c7
Commit
afea12c7
authored
Nov 27, 2012
by
Guillaume BIENKOWSKI
Committed by
Ruud
Nov 30, 2012
Browse files
Options
Downloads
Patches
Plain Diff
Log out when finished
parent
c29a8b47
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
couchpotato/core/downloaders/Synology/main.py
+23
-19
23 additions, 19 deletions
couchpotato/core/downloaders/Synology/main.py
with
23 additions
and
19 deletions
couchpotato/core/downloaders/Synology/main.py
+
23
−
19
View file @
afea12c7
...
@@ -57,31 +57,26 @@ class SynologyRPC(object):
...
@@ -57,31 +57,26 @@ class SynologyRPC(object):
self
.
username
=
username
self
.
username
=
username
self
.
password
=
password
self
.
password
=
password
self
.
session_name
=
"
DownloadStation
"
self
.
session_name
=
"
DownloadStation
"
if
username
and
password
:
if
self
.
_login
()
==
True
:
log
.
info
(
"
>Login ok
"
)
else
:
log
.
error
(
"
>Login failed
"
)
elif
username
or
password
:
log
.
error
(
'
User or password missing, not using authentication.
'
)
def
_login
(
self
):
def
_login
(
self
):
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
.
Authurl
,
args
)
response
=
self
.
_req
(
self
.
Authurl
,
args
)
if
response
[
'
success
'
]
==
True
:
if
response
[
'
success
'
]
==
True
:
self
.
sid
=
response
[
'
data
'
][
'
sid
'
]
self
.
sid
=
response
[
'
data
'
][
'
sid
'
]
log
.
info
(
"
Sid=%s
"
,
self
.
sid
)
log
.
debug
(
"
Sid=%s
"
,
self
.
sid
)
return
response
[
'
success
'
]
return
response
elif
username
or
password
:
log
.
error
(
'
User or password missing, not using authentication.
'
)
return
False
def
_logout
(
self
):
def
_logout
(
self
):
args
=
{
'
api
'
:
'
SYNO.API.Auth
'
,
'
version
'
:
1
,
'
method
'
:
'
logout
'
,
'
session
'
:
self
.
session_name
}
args
=
{
'
api
'
:
'
SYNO.API.Auth
'
,
'
version
'
:
1
,
'
method
'
:
'
logout
'
,
'
session
'
:
self
.
session_name
,
'
_sid
'
:
self
.
sid
}
response
=
self
.
_req
(
self
.
Authurl
,
args
)
return
self
.
_req
(
self
.
Authurl
,
args
)
return
response
[
'
success
'
]
def
_req
(
self
,
url
,
args
):
def
_req
(
self
,
url
,
args
):
req_url
=
url
+
'
?
'
+
urllib
.
urlencode
(
args
)
req_url
=
url
+
'
?
'
+
urllib
.
urlencode
(
args
)
#print "Trying URL: ", req_url
try
:
try
:
req_open
=
urllib2
.
urlopen
(
req_url
)
req_open
=
urllib2
.
urlopen
(
req_url
)
response
=
json
.
loads
(
req_open
.
read
())
response
=
json
.
loads
(
req_open
.
read
())
...
@@ -100,7 +95,16 @@ class SynologyRPC(object):
...
@@ -100,7 +95,16 @@ class SynologyRPC(object):
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
=
{}
# login
login
=
self
.
_login
()
if
len
(
login
)
>
0
and
login
[
'
success
'
]
==
True
:
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
.
DLurl
,
args
)
response
=
self
.
_req
(
self
.
DLurl
,
args
)
self
.
_logout
()
else
:
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