SageTV Community

SageTV Community (http://forums.sagetv.com/forums/index.php)
-   SageTV Github Development (http://forums.sagetv.com/forums/forumdisplay.php?f=53)
-   -   How to Get Channel Log FileName (http://forums.sagetv.com/forums/showthread.php?t=65503)

davidb 04-25-2018 09:00 AM

How to Get Channel Logo FileName
 
I am wanting to get the filename for each channel logo. The api call GetChannelLogo can give me the logo but I need the filename of the png image. From searching the forums I see that they are stored in the GeneratedThumbnails directory. But I am unclear how to map a name such as:
url-https3a2f2fs32eamazonaws2ecom2fschedulesdirect2fassets2fstationLogos2fs586465fh35faa2epng
which is the png image file on my system for cnn. I found from using GetAllChannels I get back for the cnn example above this:
<Channel>
<ChannelDescription>
<![CDATA[ Cable News Network ]]>
</ChannelDescription>
<ChannelNetwork/>
<IsChannelViewable>false</IsChannelViewable>
<ChannelLogoURL>
<![CDATA[
"https://s3.amazonaws.com/schedulesdirect/assets/stationLogos/s10142_h3_aa.png"
]]>
</ChannelLogoURL>
<ChannelLogoCount>1</ChannelLogoCount>
<IsChannelObject>true</IsChannelObject>
<StationID>10142</StationID>
<ChannelNumber>
<![CDATA[ 202 ]]>
</ChannelNumber>
<ChannelName>
<![CDATA[ CNN ]]>
</ChannelName>
</Channel>

The url above does show the image but I need the filename of the image already in the GeneratedThumbnails directory. I don't see any part of the url that would match up with the filename. I also looked here:
"https://github.com/google/sagetv/wiki/Schedules-Direct-EPG-(BETA)"
but couldn't find the mapping info I need.


Does anyone know how to map the filenames in the GeneratedThumbnails to a channel name or number?

Narflex 04-26-2018 11:09 AM

Try the GetChannelLogoURL API call...that won't give you the GeneratedThumbnails path...but it will give you the URL to where you can download it from.

davidb 04-26-2018 01:35 PM

I see that GetChannelLogoURL does return the url. I can go this route if I need to but using GetChannelLogoURL means I have to duplicate the channel logos that are already saved in the GeneratedThumbnails directory and will have to do a network request every 24 hours on every channel someone gets. This will have to happen for everyone that uses my IOS client. All for data that is already in the GeneratedThumbnails directory!

To illustrate what I mean the folllowing is using GetChannelLogo for CNN
Small Channel CNNHD 202 "https://s3.amazonaws.com/schedulesdirect/assets/stationLogos/s58646_h3_aa.png"
Med Channel CNNHD 202 "https://s3.amazonaws.com/schedulesdirect/assets/stationLogos/s58646_h3_aa.png"
Large Channel CNNHD 202 "https://s3.amazonaws.com/schedulesdirect/assets/stationLogos/s58646_h3_aa.png"

but buy copying the generatedThumbnails to another directory and doing a wildcard rename then loolking in explorer I see that on my system in the GeneratedThumbnails directory the cnn logo is:
url-https3a2f2fs32eamazonaws2ecom2fschedulesdirect2fassets2fstationLogos2fs586465fh35faa2epng

None of the portions of the filenames match up. If I can't find a way this could work but somewhere there has to be a mapping between the this png image in the GeneratedThumbnails directory and when sage UI needs to display the thumbnail for cnn. Sage knows how but I don't! LOL

Quote:

Originally Posted by Narflex (Post 615452)
Try the GetChannelLogoURL API call...that won't give you the GeneratedThumbnails path...but it will give you the URL to where you can download it from.


wnjj 04-26-2018 03:58 PM

Sage uses this to convert the URL to a local cache name. Is that what you're looking for? It was in MetaImage.java

Code:

myCacheFile = new File(MediaFile.THUMB_FOLDER, "url-" + convertToAsciiName(src.toString()));
.
.
.
  public static String convertToAsciiName(String s)
  {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < s.length(); i++)
    {
      char c = s.charAt(i);
      if (Character.isLetterOrDigit(c))
        sb.append(c);
      else
        sb.append(Integer.toString(c, 16));
    }
    return sb.toString();
  }

The letters & digits are left intact. The others are turned into 2-char hex (e.g. 3a = ':', 2f = '/')

davidb 04-27-2018 06:54 AM

Yes that is what I needed I just didn't know I needed it! I can now get the Channel Logos.

Thanks!

Quote:

Originally Posted by wnjj (Post 615455)
Sage uses this to convert the URL to a local cache name. Is that what you're looking for? It was in MetaImage.java

Code:

myCacheFile = new File(MediaFile.THUMB_FOLDER, "url-" + convertToAsciiName(src.toString()));
.
.
.
  public static String convertToAsciiName(String s)
  {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < s.length(); i++)
    {
      char c = s.charAt(i);
      if (Character.isLetterOrDigit(c))
        sb.append(c);
      else
        sb.append(Integer.toString(c, 16));
    }
    return sb.toString();
  }

The letters & digits are left intact. The others are turned into 2-char hex (e.g. 3a = ':', 2f = '/')



All times are GMT -6. The time now is 01:55 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.