Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
script.spotify.screensaver
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kodi
script.spotify.screensaver
Commits
fa9a24cb
Commit
fa9a24cb
authored
3 years ago
by
Benoît Harrault
Browse files
Options
Downloads
Patches
Plain Diff
Improve check spotify events file exists, clean some code
parent
f313c8e7
No related branches found
Branches containing commit
Tags
Release_0.0.34_34
Tags containing commit
1 merge request
!5
Resolve "Improve missing events file detection / fallback"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
addon.xml
+1
-1
1 addition, 1 deletion
addon.xml
gui.py
+19
-7
19 additions, 7 deletions
gui.py
with
20 additions
and
8 deletions
addon.xml
+
1
−
1
View file @
fa9a24cb
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon
id=
"script.spotify.screensaver"
<addon
id=
"script.spotify.screensaver"
name=
"Spotify Screensaver"
name=
"Spotify Screensaver"
version=
"0.0.
3
"
version=
"0.0.
4
"
provider-name=
"Benoît Harrault"
>
provider-name=
"Benoît Harrault"
>
<requires>
<requires>
<import
addon=
"xbmc.python"
version=
"2.25.0"
/>
<import
addon=
"xbmc.python"
version=
"2.25.0"
/>
...
...
This diff is collapsed.
Click to expand it.
gui.py
+
19
−
7
View file @
fa9a24cb
...
@@ -89,7 +89,12 @@ class GUI(xbmcgui.WindowXMLDialog):
...
@@ -89,7 +89,12 @@ class GUI(xbmcgui.WindowXMLDialog):
self
.
next
=
False
self
.
next
=
False
countdown
=
self
.
slideshow_time
countdown
=
self
.
slideshow_time
# display the image for the specified amount of time
# display the image for the specified amount of time
while
(
not
self
.
Monitor
.
abortRequested
())
and
(
not
self
.
stop
)
and
(
not
self
.
next
)
and
countdown
>
0
:
while
(
(
not
self
.
Monitor
.
abortRequested
())
and
(
not
self
.
stop
)
and
(
not
self
.
next
)
and
countdown
>
0
):
countdown
-=
1
countdown
-=
1
xbmc
.
sleep
(
1000
)
xbmc
.
sleep
(
1000
)
new_last_spotify_event
=
self
.
_get_last_spotify_event
()
new_last_spotify_event
=
self
.
_get_last_spotify_event
()
...
@@ -109,7 +114,6 @@ class GUI(xbmcgui.WindowXMLDialog):
...
@@ -109,7 +114,6 @@ class GUI(xbmcgui.WindowXMLDialog):
self
.
log
(
'
spotify event:
'
+
spotify_event
)
self
.
log
(
'
spotify event:
'
+
spotify_event
)
event_split
=
spotify_event
.
split
(
'
:
'
)
event_split
=
spotify_event
.
split
(
'
:
'
)
event_device
=
event_split
[
0
]
event_type
=
event_split
[
1
]
event_type
=
event_split
[
1
]
event_value
=
event_split
[
2
]
if
len
(
event_split
)
>
2
else
''
event_value
=
event_split
[
2
]
if
len
(
event_split
)
>
2
else
''
...
@@ -137,12 +141,16 @@ class GUI(xbmcgui.WindowXMLDialog):
...
@@ -137,12 +141,16 @@ class GUI(xbmcgui.WindowXMLDialog):
imageLST
=
[]
imageLST
=
[]
headers
=
{
headers
=
{
'
Authorization
'
:
'
Bearer {token}
'
.
format
(
token
=
self
.
spotify_access_token
)
'
Authorization
'
:
'
Bearer {token}
'
.
format
(
token
=
self
.
spotify_access_token
)
}
}
try
:
try
:
response
=
requests
.
get
(
SPOTIFY_API_BASE_URL
+
'
tracks/
'
+
response
=
requests
.
get
(
track_id
,
headers
=
headers
)
SPOTIFY_API_BASE_URL
+
'
tracks/
'
+
track_id
,
headers
=
headers
)
data
=
response
.
json
()
data
=
response
.
json
()
track_name
=
data
[
'
name
'
]
track_name
=
data
[
'
name
'
]
...
@@ -156,7 +164,7 @@ class GUI(xbmcgui.WindowXMLDialog):
...
@@ -156,7 +164,7 @@ class GUI(xbmcgui.WindowXMLDialog):
xbmcgui
.
ListItem
(
track_name
,
thumbnailImage
=
image_url
)
xbmcgui
.
ListItem
(
track_name
,
thumbnailImage
=
image_url
)
)
)
except
Exception
as
e
:
except
Exception
as
e
:
self
.
log
(
'
failed to get track data
'
,
xbmc
.
LOGERROR
)
self
.
log
(
'
failed to get track data
'
+
e
.
toString
()
,
xbmc
.
LOGERROR
)
return
imageLST
return
imageLST
...
@@ -171,8 +179,12 @@ class GUI(xbmcgui.WindowXMLDialog):
...
@@ -171,8 +179,12 @@ class GUI(xbmcgui.WindowXMLDialog):
self
.
close
()
self
.
close
()
def
_get_last_spotify_event
(
self
):
def
_get_last_spotify_event
(
self
):
with
open
(
LIBRESPOT_EVENT_FILE
,
'
r
'
)
as
f
:
try
:
f
=
open
(
LIBRESPOT_EVENT_FILE
,
'
r
'
)
last_event
=
f
.
readlines
()[
-
1
]
last_event
=
f
.
readlines
()[
-
1
]
finally
:
f
.
close
()
last_event
=
''
.
join
(
last_event
.
splitlines
())
last_event
=
''
.
join
(
last_event
.
splitlines
())
return
last_event
return
last_event
...
...
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