Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SickRage-1
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
SickRage-1
Commits
ace99f58
Commit
ace99f58
authored
Oct 20, 2015
by
Dustyn Gibson
Browse files
Options
Downloads
Patches
Plain Diff
Catch URLError when Kodi cant be reached for notifications
parent
665183ee
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
sickbeard/notifiers/kodi.py
+15
-11
15 additions, 11 deletions
sickbeard/notifiers/kodi.py
with
15 additions
and
11 deletions
sickbeard/notifiers/kodi.py
+
15
−
11
View file @
ace99f58
...
...
@@ -130,7 +130,7 @@ class KODINotifier:
kodiapi
=
self
.
_get_kodi_version
(
curHost
,
username
,
password
)
if
kodiapi
:
if
(
kodiapi
<=
4
)
:
if
kodiapi
<=
4
:
logger
.
log
(
u
"
Detected KODI version <= 11, using KODI HTTP API
"
,
logger
.
DEBUG
)
command
=
{
'
command
'
:
'
ExecBuiltIn
'
,
'
parameter
'
:
'
Notification(
'
+
title
.
encode
(
"
utf-8
"
)
+
'
,
'
+
message
.
encode
(
...
...
@@ -143,7 +143,7 @@ class KODINotifier:
command
=
'
{
"
jsonrpc
"
:
"
2.0
"
,
"
method
"
:
"
GUI.ShowNotification
"
,
"
params
"
:{
"
title
"
:
"
%s
"
,
"
message
"
:
"
%s
"
,
"
image
"
:
"
%s
"
},
"
id
"
:1}
'
%
(
title
.
encode
(
"
utf-8
"
),
message
.
encode
(
"
utf-8
"
),
self
.
sr_logo_url
)
notifyResult
=
self
.
_send_to_kodi_json
(
command
,
curHost
,
username
,
password
)
if
notifyResult
.
get
(
'
result
'
):
if
notifyResult
and
notifyResult
.
get
(
'
result
'
):
result
+=
curHost
+
'
:
'
+
notifyResult
[
"
result
"
].
decode
(
sickbeard
.
SYS_ENCODING
)
else
:
if
sickbeard
.
KODI_ALWAYS_ON
or
force
:
...
...
@@ -172,7 +172,7 @@ class KODINotifier:
kodiapi
=
self
.
_get_kodi_version
(
host
,
sickbeard
.
KODI_USERNAME
,
sickbeard
.
KODI_PASSWORD
)
if
kodiapi
:
if
(
kodiapi
<=
4
)
:
if
kodiapi
<=
4
:
# try to update for just the show, if it fails, do full update if enabled
if
not
self
.
_update_library
(
host
,
showName
)
and
sickbeard
.
KODI_UPDATE_FULL
:
logger
.
log
(
u
"
Single show update failed, falling back to full update
"
,
logger
.
DEBUG
)
...
...
@@ -222,7 +222,7 @@ class KODINotifier:
return
False
for
key
in
command
:
if
typ
e
(
command
[
key
]
)
==
unicode
:
if
isinstanc
e
(
command
[
key
]
,
unicode
)
:
command
[
key
]
=
command
[
key
].
encode
(
'
utf-8
'
)
enc_command
=
urllib
.
urlencode
(
command
)
...
...
@@ -240,7 +240,12 @@ class KODINotifier:
else
:
logger
.
log
(
u
"
Contacting KODI via url:
"
+
ss
(
url
),
logger
.
DEBUG
)
try
:
response
=
urllib2
.
urlopen
(
req
)
except
(
httplib
.
BadStatusLine
,
urllib2
.
URLError
)
as
e
:
logger
.
log
(
u
"
Couldn
'
t contact KODI HTTP at %r : %r
"
%
(
url
,
ex
(
e
)),
logger
.
DEBUG
)
return
False
result
=
response
.
read
().
decode
(
sickbeard
.
SYS_ENCODING
)
response
.
close
()
...
...
@@ -248,8 +253,7 @@ class KODINotifier:
return
result
except
Exception
as
e
:
logger
.
log
(
u
"
Warning: Couldn
'
t contact KODI HTTP at
"
+
ss
(
url
)
+
"
"
+
str
(
e
),
logger
.
WARNING
)
logger
.
log
(
u
"
Couldn
'
t contact KODI HTTP at %r : %r
"
%
(
url
,
ex
(
e
)),
logger
.
DEBUG
)
return
False
def
_update_library
(
self
,
host
=
None
,
showName
=
None
):
...
...
@@ -466,7 +470,7 @@ class KODINotifier:
del
shows
# we didn't find the show (exact match), thus revert to just doing a full update if enabled
if
(
tvshowid
==
-
1
)
:
if
tvshowid
==
-
1
:
logger
.
log
(
u
'
Exact show name not matched in KODI TV show list
'
,
logger
.
DEBUG
)
return
False
...
...
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