From d2d57b5c737965b7fa1c3bdb85dce070cd66131a Mon Sep 17 00:00:00 2001 From: Kevin Boyd Date: Mon, 14 Jan 2019 00:57:23 -0800 Subject: [PATCH 1/6] Convert URLs to HTTPS (and change API URL to 1.3.0) --- source/smugmugMain.brs | 2 +- source/smugmugSettings.brs | 8 ++++---- source/smugmugToolkit.brs | 22 +++++++++++----------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/source/smugmugMain.brs b/source/smugmugMain.brs index 7d78409..8d241cc 100644 --- a/source/smugmugMain.brs +++ b/source/smugmugMain.brs @@ -30,7 +30,7 @@ Sub RunUserInterface() for each h in smugmug.highlights:highlights.Push(h):next if smugmug.isLinked then - new_highlights=smugmug.getRandomRssHighlights("http://www.smugmug.com/hack/feed.mg?Type=nicknameRecentPhotos&Data="+smugmug.nickname+"&format=atom10", 1, false) + new_highlights=smugmug.getRandomRssHighlights("https://www.smugmug.com/hack/feed.mg?Type=nicknameRecentPhotos&Data="+smugmug.nickname+"&format=atom10", 1, false) if new_highlights.Count()>0 then highlights[2]=new_highlights[0] end if diff --git a/source/smugmugSettings.brs b/source/smugmugSettings.brs index d263ca4..e2cba10 100644 --- a/source/smugmugSettings.brs +++ b/source/smugmugSettings.brs @@ -61,8 +61,8 @@ Sub SlideshowSpeed() End Sub Sub DelinkPlayer() - ans=ShowDialog2Buttons("Deactivate Player","Remove link to you SmugMug account?","Confirm","Cancel") - if ans=0 then + ans=ShowDialog2Buttons("Deactivate Player","Remove link to your SmugMug account?","Confirm","Cancel") + if ans=0 then RegDelete("oauth_token","Authentication") RegDelete("oauth_secret","Authentication") m.isLinked=false @@ -112,8 +112,8 @@ Function GetFollowList() for each follow in following followReg=strTokenize(RegRead(follow,"Follow"),"|") 'For backwards compatibility, derive URL - if followReg[1]=invalid then followReg[1]="http://"+follow+".smugmug.com" - + if followReg[1]=invalid then followReg[1]="https://"+follow+".smugmug.com" + ff={nickname: follow, DisplayName: followReg[0], URL: followReg[1]} followlist.Push(ff) end for diff --git a/source/smugmugToolkit.brs b/source/smugmugToolkit.brs index 8ffea77..56706fc 100644 --- a/source/smugmugToolkit.brs +++ b/source/smugmugToolkit.brs @@ -87,7 +87,7 @@ Function CreateSmugMugConnection() As Object sha1: function(str,key):sigkey=CreateObject("roByteArray"):sigkey.fromAsciiString(key):ba=CreateObject("roByteArray"):m.hmac.Setup("sha1",sigkey):ba.FromAsciiString(str):return m.hmac.process(ba).toBase64String():end function, 'Oauth - endpoint: "http://api.smugmug.com/services/api/rest/1.2.2/", + endpoint: "https://api.smugmug.com/services/api/rest/1.3.0/", api_key: getApiKey(), api_secret: getApiSecret(), oauth_signature_method: "HMAC-SHA1", @@ -98,10 +98,10 @@ Function CreateSmugMugConnection() As Object 'Url urlencodeRFC3986: urlencodeRFC3986, urlencodeParams: urlencodeParams, - PopularUrlBase: "http://www.smugmug.com/hack/feed.mg?Type=popular&format=atom10&Data=", - RandomUrlBase: "http://www.smugmug.com/photos/random.mg?", - RecentUrlBase: "http://www.smugmug.com/hack/feed.mg?Type=nicknameRecentPhotos&format=atom10&Data=", - + PopularUrlBase: "https://www.smugmug.com/hack/feed.mg?Type=popular&format=atom10&Data=", + RandomUrlBase: "https://www.smugmug.com/photos/random.mg?", + RecentUrlBase: "https://www.smugmug.com/hack/feed.mg?Type=nicknameRecentPhotos&format=atom10&Data=", + 'Registration doRegistration: doRegistration, getRegistrationCode: getRegistrationCode, @@ -318,7 +318,7 @@ Sub BrowseMySmugMug() screen=uitkPreShowPosterMenu("","My SmugMug") - highlights=m.getRandomRssHighlights("http://www.smugmug.com/hack/feed.mg?Type=nicknameRecentPhotos&Data="+m.nickname+"&format=atom10",4) + highlights=m.getRandomRssHighlights("https://www.smugmug.com/hack/feed.mg?Type=nicknameRecentPhotos&Data="+m.nickname+"&format=atom10",4) for i=0 to 3 if highlights[i]=invalid then highlights[i]="pkg:/images/smuggy.png" @@ -558,7 +558,7 @@ Function iIsVideo() As Boolean End Function Function getImageURL(image_id, image_key, size="L" As String, ext="jpg" As String) As String - url="http://www.smugmug.com/photos/"+image_id+"_"+image_key+"-"+size+"."+ext + url="https://www.smugmug.com/photos/"+image_id+"_"+image_key+"-"+size+"."+ext return url End Function @@ -847,8 +847,8 @@ Sub BrowseSmugmugCategories() categories=GetStaticCategories() while categories.IsNext() category=categories.Next() - - rsp=m.ExecRSSRequest("http://www.smugmug.com/hack/feed.mg?Type=popularCategory&Data="+m.http.UrlEncode(category)+"&format=atom10") + + rsp=m.ExecRSSRequest("https://www.smugmug.com/hack/feed.mg?Type=popularCategory&Data="+m.http.UrlEncode(category)+"&format=atom10") if rsp=invalid then ShowErrorDialog("Bad feed response. Try again.","Bad Feed") return @@ -915,7 +915,7 @@ Sub PhotoSearch(searchtype="keyword") else if msg.isFullResult() keyword=msg.GetMessage() dialog=ShowPleaseWait("Please wait","Searching images for "+keyword) - rsp=m.ExecRSSRequest("http://smugmug.com/hack/feed.mg?Type="+searchtype+"&Data="+m.http.UrlEncode(keyword)+"&format=atom10") + rsp=m.ExecRSSRequest("https://smugmug.com/hack/feed.mg?Type="+searchtype+"&Data="+m.http.UrlEncode(keyword)+"&format=atom10") if rsp=invalid then ShowErrorDialog("Bad feed response. Try again.","Bad Feed") return @@ -1047,7 +1047,7 @@ Sub BrowseFriendsFamily() onselect = [1, ff_data[0], m, function(ff, smugmug, set_idx):smugmug.DisplayFriendsFamily(ff[set_idx]):end function] uitkDoPosterMenu(m.getFFMetaData(ff_data[0]), screen, onselect) else - uitkDoMessage("You are not linked to any friends or family. To find out more about linking to friend and family go to http://www.smugmug.com/help/friends-and-family.", screen) + uitkDoMessage("You are not linked to any friends or family. To find out more about linking to friend and family go to https://www.smugmug.com/help/friends-and-family.", screen) end if End Sub From 9a8335ff1cf184e589e8f4caa9cd78f1ae284ef3 Mon Sep 17 00:00:00 2001 From: Kevin Boyd Date: Mon, 14 Jan 2019 00:59:03 -0800 Subject: [PATCH 2/6] Enable HTTPS configuration for `roUrlTransfer`/`smugmug.http` --- source/smugmugToolkit.brs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/smugmugToolkit.brs b/source/smugmugToolkit.brs index 56706fc..c4827b3 100644 --- a/source/smugmugToolkit.brs +++ b/source/smugmugToolkit.brs @@ -113,7 +113,9 @@ Function CreateSmugMugConnection() As Object regUrlGetRegResult: "/getRegResult", regUrlWebSite: getLinkWebsite(), } - + + smugmug.http.SetCertificatesFile("common:/certs/ca-bundle.crt") + rsp=smugmug.ExecServerAPI("smugmug.service.ping") if not isxmlelement(rsp) then return invalid From 484e94546cc4a112cdbd699c4717fd38aebf567a Mon Sep 17 00:00:00 2001 From: Kevin Boyd Date: Wed, 16 Jan 2019 00:38:08 -0800 Subject: [PATCH 3/6] Use GetChannelClientId instead of GetDeviceUniqueId (deprecated) --- source/smugmugRegistration.brs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/smugmugRegistration.brs b/source/smugmugRegistration.brs index 5c1e7ee..8a466b4 100644 --- a/source/smugmugRegistration.brs +++ b/source/smugmugRegistration.brs @@ -31,8 +31,8 @@ Function doRegistration() As Integer rsp=m.ExecServerAPI("smugmug.auth.getRequestToken") m.oauth_token=rsp.auth.token@id m.oauth_token_secret=rsp.auth.token@secret - - sn = CreateObject("roDeviceInfo").GetDeviceUniqueId() + + sn = CreateObject("roDeviceInfo").GetChannelClientId() regCode = m.getRegistrationCode(sn) 'if we've failed to get the registration code, bail out, otherwise we'll From 0415f45ce519ec0662b00081f804cfdd7aa4706a Mon Sep 17 00:00:00 2001 From: Kevin Boyd Date: Wed, 16 Jan 2019 00:44:39 -0800 Subject: [PATCH 4/6] Make XML response debugging statements more consistent & helpful --- source/smugmugRegistration.brs | 5 ++++- source/smugmugToolkit.brs | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/source/smugmugRegistration.brs b/source/smugmugRegistration.brs index 8a466b4..7d99eb7 100644 --- a/source/smugmugRegistration.brs +++ b/source/smugmugRegistration.brs @@ -201,7 +201,10 @@ Function checkRegistrationStatus(sn As String, regCode As String) As Integer while true rsp = m.http.GetToString() - print rsp + + 'print "GOT: " + rsp + 'print "Reason: " + m.http.GetFailureReason() + xml=ParseXML(rsp) if xml=invalid then print "Can't parse check registration status response" diff --git a/source/smugmugToolkit.brs b/source/smugmugToolkit.brs index c4827b3..e241cb2 100644 --- a/source/smugmugToolkit.brs +++ b/source/smugmugToolkit.brs @@ -195,6 +195,10 @@ Function ExecServerAPI(method, param_list=[] As Object, nickname=invalid As Dyna else if m.session_id=invalid then m.http.SetUrl(m.endpoint+"?method=smugmug.login.anonymously&APIKey="+m.api_key) xml=m.http.GetToString() + + 'print "GOT: " + xml + 'print "Reason: " + m.http.GetFailureReason() + rsp=ParseXML(xml) if rsp=invalid then ShowErrorDialog("Error retrieving results","Unable to obtain session") @@ -218,7 +222,10 @@ Function ExecServerAPI(method, param_list=[] As Object, nickname=invalid As Dyna print apiurlstr m.http.SetUrl(apiurlstr) xml=m.http.GetToString() - 'print xml + + 'print "GOT: " + xml + 'print "Reason: " + m.http.GetFailureReason() + rsp=ParseXML(xml) if rsp=invalid then ShowErrorDialog("API return invalid. Try again later","Bad response") @@ -294,7 +301,10 @@ End Function Function ExecRSSRequest(url As String) As Dynamic m.http.SetUrl(url) xml=m.http.GetToString() - 'print xml + + 'print "GOT: " + xml + 'print "Reason: " + m.http.GetFailureReason() + rss=ParseXML(xml) if rss=invalid then return invalid From c402cebc1718413123552fd903a03ab4e4ed5f48 Mon Sep 17 00:00:00 2001 From: Kevin Boyd Date: Wed, 16 Jan 2019 00:58:50 -0800 Subject: [PATCH 5/6] Repair image key extraction and factor out deprecated image ID --- source/smugmugToolkit.brs | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/source/smugmugToolkit.brs b/source/smugmugToolkit.brs index e241cb2..b634d84 100644 --- a/source/smugmugToolkit.brs +++ b/source/smugmugToolkit.brs @@ -454,7 +454,7 @@ End Function Function aGetHighlightURL() As String if m.xml.highlight@id<>invalid then - return m.smugmug.getImageURL(m.xml.highlight@id, m.xml.highlight@key, "S") + return m.smugmug.getImageURL(m.xml.highlight@key, "S") else if m.HasPassword()=1 then return "pkg:/images/smuggy.png" else @@ -569,8 +569,10 @@ Function iIsVideo() As Boolean return 0 End Function -Function getImageURL(image_id, image_key, size="L" As String, ext="jpg" As String) As String - url="https://www.smugmug.com/photos/"+image_id+"_"+image_key+"-"+size+"."+ext +Function getImageURL(image_key, size="L" As String, ext="jpg" As String) As String + url="https://photos.smugmug.com/photos/i-"+image_key+"/0/"+size+"/i-"+image_key+"-"+size+"."+ext + 'print "getImageURL: " url + 'print " image_key: " image_key return url End Function @@ -622,24 +624,24 @@ Function newImageFromRSS(xml As Object) As Object image = CreateObject("roAssociativeArray") image.xml=xml image.GetCaption=function():return m.xml.title.GetText():end function - image.GetID=function():return getImageIdFromURL(m.xml.link@href, "id"):end function - image.GetKey=function():return getImageIdFromURL(m.xml.link@href, "key"):end function - image.GetURL=function(size):return getImageURL(m.GetID(), m.GetKey(), size):end function + image.GetKey=function():return getImageKeyFromUrl(m.xml.link@href):end function + image.GetURL=function(size):return getImageURL(m.GetKey(), size):end function return image End Function -'Parse id and key from image URL -Function getImageIdFromURL(url As String, typ As String) As String - 'Getting image string (_) - image_str=Right(url, Len(url)-InStr(1, url, "#!i=")-3) - - 'Get id - delim_pos=InStr(1, image_str, "&k=")+2 - if typ="id" then - return Left(image_str, delim_pos-1) - else if typ="key" - return Right(image_str,Len(image_str)-delim_pos) - end if +'Extract the image key from a full URL ending in "/i-{KEY}/" +Function getImageKeyFromUrl(url As String) As String + 'locate the key prefix "/i-" + start_pos=InStr(1, url, "/i-")+2 + + 'extract from the key position to the end of the string + end_str=Right(url, Len(url)-start_pos) + + 'locate the first "/" in the remaining string + end_pos=InStr(1, end_str, "/") + + 'return up to the first "/" + return Left(end_str, end_pos-1) End Function Function getImageMetaData(images As Object) From 9901acc5640c024e3e4c01b4931f286f652edd93 Mon Sep 17 00:00:00 2001 From: Kevin Boyd Date: Wed, 16 Jan 2019 01:04:01 -0800 Subject: [PATCH 6/6] Update makefile to work with newer Roku OS authentication - Also adds an example private.brs.example file for some dev key methods --- Makefile | 8 +++++--- source/private.brs.example | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 source/private.brs.example diff --git a/Makefile b/Makefile index f0f3b90..99e8c54 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ ######################################################################### -# Simple makefile for packaging Roku Flickr application +# Simple makefile for packaging Roku SmugMug application # # Makefile Usage: # > make @@ -14,7 +14,9 @@ # 2) Set the variable ROKU_DEV_TARGET in your environment to the IP # address of your Roku box. (e.g. export ROKU_DEV_TARGET=192.168.1.1. # Set in your this variable in your shell startup (e.g. .bashrc) -########################################################################## +# 3) If your roku has a password, set the ROKU_DEV_PW environment variable +# in order to allow curl requests to authenticate properly for "make install" +########################################################################## PKGREL = ../../packages ZIPREL = ../../zips SOURCEREL = .. @@ -56,7 +58,7 @@ roku-smugmug: install: roku-smugmug @echo "Installing $(APPNAME) to host $(ROKU_DEV_TARGET)" - @curl -s -S -F "mysubmit=Install" -F "archive=@$(ZIPREL)/$(APPNAME).zip" -F "passwd=" http://$(ROKU_DEV_TARGET)/plugin_install | grep "//" + @curl -s -S -F "mysubmit=Install" -F "archive=@$(ZIPREL)/$(APPNAME).zip" --anyauth "http://rokudev:$(ROKU_DEV_PW)@$(ROKU_DEV_TARGET)/plugin_install" | grep "//" pkg: install @echo "*** Creating Package ***" diff --git a/source/private.brs.example b/source/private.brs.example new file mode 100644 index 0000000..3e86f25 --- /dev/null +++ b/source/private.brs.example @@ -0,0 +1,23 @@ +' ********************************************************* +' ********************************************************* +' ** +' ** Roku DVP SmugMug Channel (BrightScript) +' ** +' ** C. Hoffman, December 2009 +' ** +' ** Copyright (c) 2009 Chris Hoffman. All Rights Reserved. +' ** +' ********************************************************* +' ********************************************************* + +Function getApiKey() As String + return "api_key" +End Function + +Function getApiSecret() As String + return "api_secret" +End Function + +Function getLinkWebsite() As String + return "http://link.example.com" +End Function