FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index Off Topic / Otros temas Chromecast backgrounds RSS
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Chromecast backgrounds RSS
Posted: Wed Jul 17, 2019 02:38 PM
I have been using John's Background switcher for years, and since I tested the Chromecast screensaver I wanted to have all those great photos available on my desktop too

Today I found a GitHub project that provides a list of Chromecast photos with 700 photos, so I used this small PRG to turn it into a valid RSS:

https://github.com/FiveTechSoft/chromecast-backgrounds

Code (fw): Select all Collapse
#define CRLF Chr( 13 ) + Chr( 10 )

function Main()
    
   local aLines := HB_aTokens( MemoRead( "README.md" ), Chr( 10 ) )
   local cRSS
 
   cRSS = '<?xml version="1.0" encoding="utf-8"?>' + CRLF
   cRSS += '<rss version="2.0">' + CRLF
   cRSS += '<channel>' + CRLF
   cRSS += "<title>chromecast-backgrounds</title>" + CRLF
   cRSS += "<link>https://github.com/FiveTechSoft/chromecast-backgrounds</link>" + CRLF 
   cRSS += "<description>dconnolly chromecast-backgrounds collection</description>" + CRLF
 
   AEval( aLines, { | cLine, n | cRSS += StrTran( StrTran( cLine, "![](", "<item>" + CRLF + ;
          "<title>" + AllTrim( Str( n ) ) + "</title>" + CRLF + "<link>" ), ")",;
          "</link>" + CRLF + "</item>" ) + CRLF } )
   
   hb_MemoWrit( "test.rss", SubStr( cRSS, 1, Len( cRSS ) - 2 ) + "</channel>" + CRLF + "</rss>" )

return nil


So I forked the GitHub project, and added the RSS feed and it is working really fine from John's Background switcher:
https://raw.githubusercontent.com/FiveTechSoft/chromecast-backgrounds/master/test.rss
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: Chromecast backgrounds RSS
Posted: Wed Jul 17, 2019 05:28 PM

Impresionantes fotos.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Chromecast backgrounds RSS
Posted: Wed Jul 17, 2019 07:39 PM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Chromecast backgrounds RSS
Posted: Sat Apr 04, 2020 09:11 PM
Here there is a JSON file with lots of ChromeCast pictures:
https://chromecastbg.alexmeub.com/images.v9.json

This PRG generates a RSS file from it:
Code (fw): Select all Collapse
#define CRLF Chr( 13 ) + Chr( 10 )

function Main()

   local aImages := hb_JsonDecode( MemoRead( "c:\temp\images.v9.json" ) )
   local hImage, cRSS
 
   cRSS = '<?xml version="1.0" encoding="utf-8"?>' + CRLF
   cRSS += '<rss version="2.0">' + CRLF
   cRSS += '<channel>' + CRLF
   cRSS += "<title>chromecast-backgrounds</title>" + CRLF
   cRSS += "<link>https://github.com/FiveTechSoft/chromecast-backgrounds</link>" + CRLF
   cRSS += "<description>dconnolly chromecast-backgrounds collection</description>" + CRLF
   
   for each hImage in aImages
      cRSS += "<item>" + CRLF
      cRSS += "<title>" + AllTrim( Str( hImage:__enumIndex ) ) + "</title>" + CRLF
      cRSS += "<link>" + hImage[ "url" ] + "</link>" + CRLF
      cRSS += "</item>" + CRLF
   next
   
   cRSS += "</channel>" + CRLF
   cRSS += "</rss>"
   
   hb_MemoWrit( "c:\temp\images.v9.rss", cRSS )

return nil


Here it is the resulting RSS file:
https://raw.githubusercontent.com/FiveTechSoft/chromecast-backgrounds/master/images.v9.rss
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Chromecast backgrounds RSS
Posted: Sun Apr 05, 2020 05:49 AM
I found an easy way to get all the photos that ChromeCast uses from its url:
https://clients3.google.com/cast/chromecast/home

Simply open it from Chrome, inspect it using F12 and select "network", click on "Preserve log" and wait...:


Let it be there for hours, the log will grow, finally click on "down arrow" (Export HAR) and it will create a JSON file on disk.

Now use this PRG to extract the URLs from it:
rss.prg
Code (fw): Select all Collapse
#define CRLF Chr( 13 ) + Chr( 10 )

function Main()

   local hInfo := hb_JsonDecode( MemoRead( "c:\Users\anto\Downloads\clients3.google.com.har" ) )
   local hEntry, cRSS

   cRSS = '<?xml version="1.0" encoding="utf-8"?>' + CRLF
   cRSS += '<rss version="2.0">' + CRLF
   cRSS += '<channel>' + CRLF
   cRSS += "<title>chromecast-backgrounds</title>" + CRLF
   cRSS += "<link>https://github.com/FiveTechSoft/chromecast-backgrounds</link>" + CRLF
   cRSS += "<description>chromecast-backgrounds collection</description>" + CRLF
   
   for each hEntry in hInfo[ "log" ][ "entries" ]
      if ! Empty( hEntry[ "request" ][ "method" ] )
         cRSS += "<item>" + CRLF
         cRSS += "<title>" + AllTrim( Str( hEntry:__enumIndex ) ) + "</title>" + CRLF
         cRSS += "<link>" + hEntry[ "request" ][ "url" ] + "</link>" + CRLF
         cRSS += "</item>" + CRLF
      endif 
   next        

   cRSS += "</channel>" + CRLF
   cRSS += "</rss>"
   
   hb_MemoWrit( "c:\temp\clients3.google.com.har.rss", cRSS )

return nil


It will create a RSS file with all the photos URLs into it that you can use from John's Background Switcher for your PC desktop images:
https://raw.githubusercontent.com/FiveTechSoft/chromecast-backgrounds/master/clients3.google.com.har.rss
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Chromecast backgrounds RSS
Posted: Sun Apr 05, 2020 06:16 AM
A modified version to post the images here:

phpbb.prg
Code (fw): Select all Collapse
#define CRLF Chr( 13 ) + Chr( 10 )

function Main()

   local hInfo := hb_JsonDecode( MemoRead( "c:\Users\anto\Downloads\clients3.google.com.har" ) )
   local hEntry, cRSS := ""

   for each hEntry in hInfo[ "log" ][ "entries" ]
      if ! Empty( hEntry[ "request" ][ "method" ] )
         cRSS += "<img src=""%20+%20hEntry[%20"request"%20][%20"url"%20]%20+%20"" alt="" loading="lazy">" + CRLF
      endif 
   next        
   
   hb_MemoWrit( "c:\temp\phpbb.post", cRSS )

return nil







































































































































































regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Chromecast backgrounds RSS
Posted: Sun Apr 05, 2020 06:28 AM
This version creates a md file that you can post on github:

md.prg
Code (fw): Select all Collapse
#define CRLF Chr( 13 ) + Chr( 10 )

function Main()

   local hInfo := hb_JsonDecode( MemoRead( "c:\Users\anto\Downloads\clients3.google.com.har" ) )
   local hEntry, cRSS := ""

   for each hEntry in hInfo[ "log" ][ "entries" ]
      if ! Empty( hEntry[ "request" ][ "method" ] )
         cRSS += "![](" + hEntry[ "request" ][ "url" ] + ")" + CRLF
      endif 
   next        
   
   hb_MemoWrit( "c:\temp\backgrounds.md", cRSS )

return nil


https://github.com/FiveTechSoft/chromecast-backgrounds/blob/master/backgrounds.md
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Chromecast backgrounds RSS
Posted: Sun Apr 05, 2020 06:54 AM
And a great music to listen meanwhile you watch the images :-)

https://journeyscapesradio.blogspot.com/p/radionomy-player.html
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Chromecast backgrounds RSS
Posted: Sun Apr 05, 2020 11:02 PM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Chromecast backgrounds RSS
Posted: Mon Apr 06, 2020 07:14 AM
After saving the Chrome log file, use this PRG to save the images to local files:

saveimages.prg
Code (fw): Select all Collapse
#define CRLF Chr( 13 ) + Chr( 10 )

function Main()

   local hInfo := hb_JsonDecode( MemoRead( "c:\Users\anto\Downloads\clients3.google.com.har" ) )
   local hEntry, aImages := {}, cImage

   for each hEntry in hInfo[ "log" ][ "entries" ]
      if ! Empty( hEntry[ "request" ][ "method" ] )
         if AScan( aImages, hEntry[ "request" ][ "url" ] ) == 0 
            AAdd( aImages, hEntry[ "request" ][ "url" ] ) 
            hb_MemoWrit( "c:\temp\" + AllTrim( Str( Len( aImages ) ) ) + ".jfif",;
                         WebImage( hEntry[ "request" ][ "url" ] ) )
         endif   
      endif
   next        
   
   MsgInfo( "done" )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Chromecast backgrounds RSS
Posted: Tue Apr 14, 2020 07:18 AM
Enhanced version that saves all the photos, and erase duplicated photos

chromebg.prg
Code (fw): Select all Collapse
// Download images from the ChromeCast backgrounds images log file in Chrome network inspector

#define CRLF Chr( 13 ) + Chr( 10 )

function Main()

   local hInfo := hb_JsonDecode( MemoRead( "c:\Users\anto\Downloads\clients3.google.com.har2.har" ) )
   local hEntry, aImages := {}, cImage, aFiles

   for each hEntry in hInfo[ "log" ][ "entries" ]
      if ! Empty( hEntry[ "request" ][ "method" ] )
         if AScan( aImages, hEntry[ "request" ][ "url" ] ) == 0 
            AAdd( aImages, hEntry[ "request" ][ "url" ] ) 
            hb_MemoWrit( "c:\Users\anto\pictures\" + DToS( Date() ) + "_" + hb_ntos( Seconds() ) + ".jfif",;
                         WebImage( hEntry[ "request" ][ "url" ] ) )
         endif   
      endif
   next        

   aFiles = Directory( "c:\Users\anto\pictures\*.jfif" )
   ASort( aFiles,,, { | x, y | If( x[ 2 ] == y[ 2 ], FErase( "c:\Users\anto\pictures\" + y[ 1 ] ),), x[ 2 ] < y[ 2 ] } )
   
   MsgInfo( "done" )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion