Mark movies watched or unwatched
This commit is contained in:
parent
3a003d6361
commit
c382464647
|
@ -6,6 +6,7 @@
|
|||
<field id="movieID" type="string" />
|
||||
<field id="description" type="string" />
|
||||
<field id="favorite" type="boolean" />
|
||||
<field id="watched" type="boolean" />
|
||||
<field id="seasons" type="associativearray" />
|
||||
<field id="full_data" type="associativearray" onChange="setFields" />
|
||||
<function name="favorite_toggle" />
|
||||
|
@ -23,6 +24,7 @@
|
|||
end if
|
||||
m.top.description = datum.overview
|
||||
m.top.favorite = datum.UserData.isFavorite
|
||||
m.top.watched = datum.UserData.played
|
||||
end sub
|
||||
]]>
|
||||
</script>
|
||||
|
|
|
@ -33,7 +33,7 @@ sub itemContentChanged()
|
|||
setFieldText("tagline", itemData.taglines[0])
|
||||
end if
|
||||
setFavoriteColor()
|
||||
m.top.itemContent.observeField("favorite", "setFavoriteColor")
|
||||
setWatchedColor()
|
||||
end sub
|
||||
|
||||
sub setFieldText(field as string, value)
|
||||
|
@ -84,7 +84,18 @@ sub setFavoriteColor()
|
|||
fave_button.textColor = "0xddddddff"
|
||||
fave_button.focusedTextColor = "#262626ff"
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub setWatchedColor()
|
||||
watched = m.top.itemContent.watched
|
||||
watched_button = m.top.findNode("buttons").getChild(2)
|
||||
if watched
|
||||
watched_button.textColor = "#ff0000ff"
|
||||
watched_button.focusedTextColor = "#992626ff"
|
||||
else
|
||||
watched_button.textColor = "0xddddddff"
|
||||
watched_button.focusedTextColor = "#262626ff"
|
||||
end if
|
||||
end sub
|
||||
|
||||
function round(f as Float) as Integer
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
if datum.posterURL <> invalid
|
||||
m.top.posterURL = datum.posterURL
|
||||
else
|
||||
""
|
||||
m.top.posterURL = ""
|
||||
end if
|
||||
m.top.description = datum.overview
|
||||
end sub
|
||||
|
|
|
@ -28,5 +28,11 @@ sub themeScene(scene)
|
|||
if overhang <> invalid
|
||||
overhang.logoUri = "pkg:/images/logo.png"
|
||||
end if
|
||||
|
||||
end sub
|
||||
|
||||
function leftPad(base as string, fill as string, length as integer) as string
|
||||
while len(base) < length
|
||||
base = fill + base
|
||||
end while
|
||||
return base
|
||||
end function
|
||||
|
|
|
@ -200,16 +200,22 @@ sub ShowMovieDetails(movie_id)
|
|||
else if nodeEventQ(msg, "buttonSelected")
|
||||
button = msg.getROSGNode()
|
||||
' TODO - a better way to verify buttonSelected is in fact "play", etc
|
||||
if button.buttonSelected = 0
|
||||
if button.buttonSelected = 0 ' Play
|
||||
showVideoPlayer(movie_id)
|
||||
else if button.buttonSelected = 3
|
||||
else if button.buttonSelected = 2 ' Watched
|
||||
if content.watched
|
||||
UnmarkItemWatched(movie_id)
|
||||
else
|
||||
MarkItemWatched(movie_id)
|
||||
end if
|
||||
content.watched = not content.watched
|
||||
else if button.buttonSelected = 3 ' Favorite
|
||||
if content.favorite
|
||||
UnmarkItemFavorite(movie_id)
|
||||
else
|
||||
MarkItemFavorite(movie_id)
|
||||
end if
|
||||
content.favorite = not content.favorite
|
||||
'content.callfunc("favorite_toggle")
|
||||
end if
|
||||
else
|
||||
print msg
|
||||
|
|
|
@ -10,3 +10,25 @@ function UnmarkItemFavorite(id as String)
|
|||
resp.setRequest("DELETE")
|
||||
return getJson(resp)
|
||||
end function
|
||||
|
||||
function MarkItemWatched(id as String)
|
||||
date = CreateObject("roDateTime")
|
||||
date.toLocalTime()
|
||||
dateStr = stri(date.getYear()).trim()
|
||||
dateStr += leftPad(stri(date.getMonth()).trim(), "0", 2)
|
||||
dateStr += leftPad(stri(date.getDayOfMonth()).trim(), "0", 2)
|
||||
dateStr += leftPad(stri(date.getHours()).trim(), "0", 2)
|
||||
dateStr += leftPad(stri(date.getMinutes()).trim(), "0", 2)
|
||||
dateStr += leftPad(stri(date.getSeconds()).trim(), "0", 2)
|
||||
|
||||
url = Substitute("Users/{0}/PlayedItems/{1}", get_setting("active_user"), id)
|
||||
resp = APIRequest(url, {"DatePlayed": dateStr})
|
||||
data = postJson(resp)
|
||||
end function
|
||||
|
||||
function UnmarkItemWatched(id as String)
|
||||
url = Substitute("Users/{0}/PlayedItems/{1}", get_setting("active_user"), id)
|
||||
resp = APIRequest(url)
|
||||
resp.setRequest("DELETE")
|
||||
return getJson(resp)
|
||||
end function
|
||||
|
|
Loading…
Reference in New Issue
Block a user