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
0a7765f6
Commit
0a7765f6
authored
12 years ago
by
Ruud
Browse files
Options
Downloads
Patches
Plain Diff
uTorrent status support. closes #1391
Thanks to Stourwalk
parent
c2144587
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
couchpotato/core/downloaders/utorrent/main.py
+58
-2
58 additions, 2 deletions
couchpotato/core/downloaders/utorrent/main.py
couchpotato/core/plugins/renamer/main.py
+1
-1
1 addition, 1 deletion
couchpotato/core/plugins/renamer/main.py
with
59 additions
and
3 deletions
couchpotato/core/downloaders/utorrent/main.py
+
58
−
2
View file @
0a7765f6
...
@@ -6,6 +6,7 @@ from hashlib import sha1
...
@@ -6,6 +6,7 @@ from hashlib import sha1
from
multipartpost
import
MultipartPostHandler
from
multipartpost
import
MultipartPostHandler
import
cookielib
import
cookielib
import
httplib
import
httplib
import
json
import
re
import
re
import
time
import
time
import
urllib
import
urllib
...
@@ -64,6 +65,59 @@ class uTorrent(Downloader):
...
@@ -64,6 +65,59 @@ class uTorrent(Downloader):
log
.
error
(
'
Failed to send torrent to uTorrent: %s
'
,
err
)
log
.
error
(
'
Failed to send torrent to uTorrent: %s
'
,
err
)
return
False
return
False
def
getAllDownloadStatus
(
self
):
log
.
debug
(
'
Checking uTorrent download status.
'
)
# Load host from config and split out port.
host
=
self
.
conf
(
'
host
'
).
split
(
'
:
'
)
if
not
isInt
(
host
[
1
]):
log
.
error
(
'
Config properties are not filled in correctly, port is missing.
'
)
return
False
try
:
self
.
utorrent_api
=
uTorrentAPI
(
host
[
0
],
port
=
host
[
1
],
username
=
self
.
conf
(
'
username
'
),
password
=
self
.
conf
(
'
password
'
))
except
Exception
,
err
:
log
.
error
(
'
Failed to get uTorrent object: %s
'
,
err
)
return
False
data
=
''
try
:
data
=
self
.
utorrent_api
.
get_status
()
queue
=
json
.
loads
(
data
)
if
queue
.
get
(
'
error
'
):
log
.
error
(
'
Error getting data from uTorrent: %s
'
,
queue
.
get
(
'
error
'
))
return
False
except
Exception
,
err
:
log
.
error
(
'
Failed to get status from uTorrent: %s
'
,
err
)
return
False
if
queue
.
get
(
'
torrents
'
,
[])
==
[]:
log
.
debug
(
'
Nothing in queue
'
)
return
False
statuses
=
[]
# Get torrents
for
item
in
queue
.
get
(
'
torrents
'
,
[]):
# item[21] = Paused | Downloading | Seeding | Finished
status
=
'
busy
'
if
item
[
21
]
==
'
Finished
'
or
item
[
21
]
==
'
Seeding
'
:
status
=
'
completed
'
statuses
.
append
({
'
id
'
:
item
[
0
],
'
name
'
:
item
[
2
],
'
status
'
:
status
,
'
original_status
'
:
item
[
1
],
'
timeleft
'
:
item
[
10
],
})
return
statuses
class
uTorrentAPI
(
object
):
class
uTorrentAPI
(
object
):
...
@@ -94,9 +148,7 @@ class uTorrentAPI(object):
...
@@ -94,9 +148,7 @@ class uTorrentAPI(object):
try
:
try
:
open_request
=
self
.
opener
.
open
(
request
)
open_request
=
self
.
opener
.
open
(
request
)
response
=
open_request
.
read
()
response
=
open_request
.
read
()
log
.
debug
(
'
response: %s
'
,
response
)
if
response
:
if
response
:
log
.
debug
(
'
uTorrent action successfull
'
)
return
response
return
response
else
:
else
:
log
.
debug
(
'
Unknown failure sending command to uTorrent. Return text is: %s
'
,
response
)
log
.
debug
(
'
Unknown failure sending command to uTorrent. Return text is: %s
'
,
response
)
...
@@ -133,3 +185,7 @@ class uTorrentAPI(object):
...
@@ -133,3 +185,7 @@ class uTorrentAPI(object):
def
pause_torrent
(
self
,
hash
):
def
pause_torrent
(
self
,
hash
):
action
=
"
action=pause&hash=%s
"
%
hash
action
=
"
action=pause&hash=%s
"
%
hash
return
self
.
_request
(
action
)
return
self
.
_request
(
action
)
def
get_status
(
self
):
action
=
"
list=1
"
return
self
.
_request
(
action
)
This diff is collapsed.
Click to expand it.
couchpotato/core/plugins/renamer/main.py
+
1
−
1
View file @
0a7765f6
...
@@ -566,7 +566,7 @@ class Renamer(Plugin):
...
@@ -566,7 +566,7 @@ class Renamer(Plugin):
found
=
False
found
=
False
for
item
in
statuses
:
for
item
in
statuses
:
if
item
[
'
name
'
]
==
nzbname
or
getImdb
(
item
[
'
name
'
])
==
movie_dict
[
'
library
'
][
'
identifier
'
]:
if
item
[
'
name
'
]
==
nzbname
or
rel_dict
[
'
info
'
][
'
name
'
]
in
item
[
'
name
'
]
or
getImdb
(
item
[
'
name
'
])
==
movie_dict
[
'
library
'
][
'
identifier
'
]:
timeleft
=
'
N/A
'
if
item
[
'
timeleft
'
]
==
-
1
else
item
[
'
timeleft
'
]
timeleft
=
'
N/A
'
if
item
[
'
timeleft
'
]
==
-
1
else
item
[
'
timeleft
'
]
log
.
debug
(
'
Found %s: %s, time to go: %s
'
,
(
item
[
'
name
'
],
item
[
'
status
'
].
upper
(),
timeleft
))
log
.
debug
(
'
Found %s: %s, time to go: %s
'
,
(
item
[
'
name
'
],
item
[
'
status
'
].
upper
(),
timeleft
))
...
...
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