Loading resource from an URL returns 0 bytes (Redirection?)

So when I try to load a cover to make the DirectoryObject more appealing it seems 0 bytes are returned.

(Image loads fine in my browser)

 

Code trying to load the image:

@route(PREFIX + '/anime')
def Animelist():
oc = ObjectContainer(title2 = 'All anime')
animes = Masterani().animes()
for anime in animes:
id = anime['id']
name = anime['name']
summary = anime['description']
cover = anime['mal_image']
Log.Info(cover)
oc.add(DirectoryObject(key = Callback(Episodelist, anime_id = id, anime_name = name), title = name, summary = summary, thumb = Resource.ContentsOfURLWithFallback(url = cover, fallback = R(COVER))))
 
if len(oc) < 1:
return ObjectContainer(header = 'Empty', message="Unable to load anime shows!")   
return oc

Log file:

2014-12-01 23:19:24,327 (7fff7e3ab300) :  INFO (core:347) - Starting framework core - Version: 2.5.0, Build: a51033b (Mon Jul 28 12:19:14 UTC 2014)
2014-12-01 23:19:24,327 (7fff7e3ab300) :  DEBUG (core:359) - Using the elevated policy
2014-12-01 23:19:24,327 (7fff7e3ab300) :  DEBUG (core:448) - Starting runtime component.
2014-12-01 23:19:24,329 (7fff7e3ab300) :  DEBUG (core:448) - Starting caching component.
2014-12-01 23:19:24,329 (7fff7e3ab300) :  DEBUG (core:448) - Starting data component.
2014-12-01 23:19:24,329 (7fff7e3ab300) :  DEBUG (core:448) - Starting networking component.
2014-12-01 23:19:24,341 (7fff7e3ab300) :  DEBUG (networking:288) - Loaded HTTP cookies
2014-12-01 23:19:24,357 (7fff7e3ab300) :  DEBUG (networking:458) - Setting the default network timeout to 20.0
2014-12-01 23:19:24,361 (7fff7e3ab300) :  DEBUG (core:448) - Starting localization component.
2014-12-01 23:19:24,361 (7fff7e3ab300) :  INFO (localization:408) - Setting the default locale to en-us
2014-12-01 23:19:24,362 (7fff7e3ab300) :  DEBUG (core:448) - Starting messaging component.
2014-12-01 23:19:24,362 (10bc84000) :  DEBUG (networking:172) - Requesting 'http://127.0.0.1:32400/system/messaging/clear_events/com.plexapp.plugins.animehd'
2014-12-01 23:19:24,362 (7fff7e3ab300) :  DEBUG (core:448) - Starting debugging component.
2014-12-01 23:19:24,364 (7fff7e3ab300) :  DEBUG (core:448) - Starting services component.
2014-12-01 23:19:24,364 (7fff7e3ab300) :  DEBUG (core:448) - Starting myplex component.
2014-12-01 23:19:24,364 (7fff7e3ab300) :  DEBUG (core:448) - Starting notifications component.
2014-12-01 23:19:24,604 (7fff7e3ab300) :  DEBUG (accessor:68) - Creating a new model access point for provider com.plexapp.plugins.animehd in namespace 'metadata'
2014-12-01 23:19:24,609 (7fff7e3ab300) :  DEBUG (networking:172) - Requesting 'http://127.0.0.1:32400/:/plugins/com.plexapp.system/resourceHashes'
2014-12-01 23:19:24,628 (10c0c7000) :  DEBUG (services:265) - Plug-in is not daemonized - loading services from system
2014-12-01 23:19:24,628 (7fff7e3ab300) :  DEBUG (runtime:1111) - Created a thread named 'load_all_services'
2014-12-01 23:19:24,629 (10c0c7000) :  DEBUG (networking:172) - Requesting 'http://127.0.0.1:32400/:/plugins/com.plexapp.system/messaging/function/X0J1bmRsZVNlcnZpY2U6QWxsU2VydmljZXM_/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoxCmRpY3QKMApyMAo_'
2014-12-01 23:19:24,630 (7fff7e3ab300) :  DEBUG (runtime:1111) - Created a thread named 'get_server_info'
2014-12-01 23:19:24,630 (7fff7e3ab300) :  DEBUG (core:150) - Finished starting framework core
2014-12-01 23:19:24,631 (7fff7e3ab300) :  DEBUG (core:558) - Loading plug-in code
2014-12-01 23:19:24,631 (10c8cd000) :  DEBUG (networking:172) - Requesting 'http://127.0.0.1:32400'
2014-12-01 23:19:24,658 (7fff7e3ab300) :  DEBUG (core:564) - Finished loading plug-in code
2014-12-01 23:19:24,658 (7fff7e3ab300) :  DEBUG (runtime:640) - Adding a prefix handler for 'AnimeHD' ('/video/animehd')
2014-12-01 23:19:24,663 (7fff7e3ab300) :  INFO (core:609) - Started plug-in
2014-12-01 23:19:24,663 (7fff7e3ab300) :  DEBUG (socketinterface:160) - Starting socket server
2014-12-01 23:19:24,665 (7fff7e3ab300) :  DEBUG (runtime:1111) - Created a thread named 'start'
2014-12-01 23:19:24,665 (7fff7e3ab300) :  INFO (socketinterface:184) - Socket server started on port 61700
2014-12-01 23:19:24,666 (7fff7e3ab300) :  INFO (pipeinterface:25) - Entering run loop
2014-12-01 23:19:24,666 (7fff7e3ab300) :  DEBUG (runtime:717) - Handling request GET /:/prefixes
2014-12-01 23:19:24,669 (7fff7e3ab300) :  DEBUG (runtime:814) - Found route matching /:/prefixes
2014-12-01 23:19:24,672 (10c8cd000) :  DEBUG (core:536) - Machine identifier is 66b5841817ea58c438d6f14b1fbc231fb72b299e
2014-12-01 23:19:24,672 (10c8cd000) :  DEBUG (core:537) - Server version is 0.9.9.14.531-7eef8c6
2014-12-01 23:19:24,783 (10c0c7000) :  DEBUG (services:362) - Loaded services
2014-12-01 23:19:24,789 (10c4ca000) :  DEBUG (services:438) - No shared code to load
2014-12-01 23:19:24,789 (7fff7e3ab300) :  DEBUG (runtime:918) - Response: [200] MediaContainer, 442 bytes
2014-12-01 23:19:46,309 (10c0c7000) :  DEBUG (runtime:717) - Handling request GET /video/animehd
2014-12-01 23:19:46,311 (10c0c7000) :  DEBUG (runtime:49) - Received packed state data (1416 bytes)
2014-12-01 23:19:46,315 (10c0c7000) :  DEBUG (runtime:814) - Found route matching /video/animehd
2014-12-01 23:19:46,316 (10c0c7000) :  DEBUG (base:125) - Checking if com.plexapp.plugins.animehd is broken
2014-12-01 23:19:46,317 (10c0c7000) :  DEBUG (networking:172) - Requesting 'http://127.0.0.1:32400/:/plugins/com.plexapp.system/messaging/function/X1N0b3JlU2VydmljZTpJc0NoYW5uZWxCcm9rZW4_/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoxCmRpY3QKMQpzMjcKY29tLnBsZXhhcHAucGx1Z2lucy5hbmltZWhkczEwCmlkZW50aWZpZXJyMAo_'
2014-12-01 23:19:46,333 (10c0c7000) :  DEBUG (runtime:106) - Sending packed state data (1444 bytes)
2014-12-01 23:19:46,333 (10c0c7000) :  DEBUG (runtime:918) - Response: [200] MediaContainer, 495 bytes
2014-12-01 23:19:47,151 (10c0c7000) :  DEBUG (runtime:717) - Handling request GET /video/animehd
2014-12-01 23:19:47,153 (10c0c7000) :  DEBUG (runtime:49) - Received packed state data (1416 bytes)
2014-12-01 23:19:47,158 (10c0c7000) :  DEBUG (runtime:814) - Found route matching /video/animehd
2014-12-01 23:19:47,159 (10c0c7000) :  DEBUG (base:125) - Checking if com.plexapp.plugins.animehd is broken
2014-12-01 23:19:47,160 (10c0c7000) :  DEBUG (networking:172) - Requesting 'http://127.0.0.1:32400/:/plugins/com.plexapp.system/messaging/function/X1N0b3JlU2VydmljZTpJc0NoYW5uZWxCcm9rZW4_/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoxCmRpY3QKMQpzMjcKY29tLnBsZXhhcHAucGx1Z2lucy5hbmltZWhkczEwCmlkZW50aWZpZXJyMAo_'
2014-12-01 23:19:47,178 (10c0c7000) :  DEBUG (runtime:106) - Sending packed state data (1444 bytes)
2014-12-01 23:19:47,178 (10c0c7000) :  DEBUG (runtime:918) - Response: [200] MediaContainer, 495 bytes
2014-12-01 23:19:47,196 (10c0c7000) :  DEBUG (runtime:717) - Handling request GET /video/animehd/anime
2014-12-01 23:19:47,197 (10c0c7000) :  DEBUG (runtime:49) - Received packed state data (1416 bytes)
2014-12-01 23:19:47,201 (10c0c7000) :  DEBUG (runtime:814) - Found route matching /video/animehd/anime
2014-12-01 23:19:47,201 (10c0c7000) :  DEBUG (networking:172) - Requesting 'http://masteranime.app/api_v2/animes'
2014-12-01 23:19:47,634 (10c0c7000) :  INFO (__init__:28) - https://static.hummingbird.me/anime/poster_images/000/007/882/large/IERBT2u.jpg?1416325442
2014-12-01 23:19:47,635 (10c0c7000) :  INFO (__init__:28) - https://static.hummingbird.me/anime/poster_images/000/008/452/large/PtbL5rD.jpg?1408464496
2014-12-01 23:19:47,636 (10c0c7000) :  INFO (__init__:28) - https://static.hummingbird.me/anime/poster_images/000/008/147/large/iimULfF3qgJiE.jpg?1416444566
2014-12-01 23:19:47,637 (10c0c7000) :  INFO (__init__:28) - https://static.hummingbird.me/anime/poster_images/000/007/000/large/ibn1YAUNCr0I4g.jpg?1416541456
2014-12-01 23:19:47,638 (10c0c7000) :  INFO (__init__:28) - https://static.hummingbird.me/anime/poster_images/000/007/863/large/iDr2UPBEr4trZ.jpg?1416370892
2014-12-01 23:19:47,638 (10c0c7000) :  INFO (__init__:28) - https://static.hummingbird.me/anime/poster_images/000/006/589/large/itJTVuFcCULzK.jpg?1416428763
2014-12-01 23:19:47,639 (10c0c7000) :  INFO (__init__:28) - https://static.hummingbird.me/anime/poster_images/000/008/607/large/47481d23jw1ejd2v508bpj20nk0xcwqx.jpg?1416323699
2014-12-01 23:19:47,641 (10c0c7000) :  DEBUG (runtime:106) - Sending packed state data (1444 bytes)
2014-12-01 23:19:47,642 (10c0c7000) :  DEBUG (runtime:918) - Response: [200] MediaContainer, 8511 bytes
2014-12-01 23:19:47,685 (10c0c7000) :  DEBUG (runtime:717) - Handling request GET /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback?fallback=%2F%3A%2Fplugins%2Fcom.plexapp.plugins.animehd%2Fresources%2Fcover-default.jpg%3Ft%3D1415728749&urls=https%253A%2F%2Fstatic.hummingbird.me%2Fanime%2Fposter_images%2F000%2F007%2F882%2Flarge%2FIERBT2u.jpg%253F1416325442
2014-12-01 23:19:47,710 (10c0c7000) :  DEBUG (runtime:814) - Found route matching /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback
2014-12-01 23:19:47,711 (10c0c7000) :  DEBUG (networking:237) - Fetching HTTP headers for 'https://static.hummingbird.me/anime/poster_images/000/007/882/large/IERBT2u.jpg?1416325442'
2014-12-01 23:19:47,738 (10c4ca000) :  DEBUG (runtime:717) - Handling request GET /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback?fallback=%2F%3A%2Fplugins%2Fcom.plexapp.plugins.animehd%2Fresources%2Fcover-default.jpg%3Ft%3D1415728749&urls=https%253A%2F%2Fstatic.hummingbird.me%2Fanime%2Fposter_images%2F000%2F007%2F882%2Flarge%2FIERBT2u.jpg%253F1416325442
2014-12-01 23:19:47,741 (10c4ca000) :  DEBUG (runtime:814) - Found route matching /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback
2014-12-01 23:19:47,743 (10c4ca000) :  DEBUG (networking:237) - Fetching HTTP headers for 'https://static.hummingbird.me/anime/poster_images/000/007/882/large/IERBT2u.jpg?1416325442'
2014-12-01 23:19:47,749 (10c8cd000) :  DEBUG (runtime:717) - Handling request GET /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback?fallback=%2F%3A%2Fplugins%2Fcom.plexapp.plugins.animehd%2Fresources%2Fcover-default.jpg%3Ft%3D1415728749&urls=https%253A%2F%2Fstatic.hummingbird.me%2Fanime%2Fposter_images%2F000%2F008%2F452%2Flarge%2FPtbL5rD.jpg%253F1408464496
2014-12-01 23:19:47,751 (10c8cd000) :  DEBUG (runtime:814) - Found route matching /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback
2014-12-01 23:19:47,752 (10c8cd000) :  DEBUG (networking:237) - Fetching HTTP headers for 'https://static.hummingbird.me/anime/poster_images/000/008/452/large/PtbL5rD.jpg?1408464496'
2014-12-01 23:19:47,789 (10d0d3000) :  DEBUG (runtime:717) - Handling request GET /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback?fallback=%2F%3A%2Fplugins%2Fcom.plexapp.plugins.animehd%2Fresources%2Fcover-default.jpg%3Ft%3D1415728749&urls=https%253A%2F%2Fstatic.hummingbird.me%2Fanime%2Fposter_images%2F000%2F008%2F147%2Flarge%2FiimULfF3qgJiE.jpg%253F1416444566
2014-12-01 23:19:47,791 (10d0d3000) :  DEBUG (runtime:814) - Found route matching /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback
2014-12-01 23:19:47,793 (10d0d3000) :  DEBUG (networking:237) - Fetching HTTP headers for 'https://static.hummingbird.me/anime/poster_images/000/008/147/large/iimULfF3qgJiE.jpg?1416444566'
2014-12-01 23:19:47,800 (10d4d6000) :  DEBUG (runtime:717) - Handling request GET /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback?fallback=%2F%3A%2Fplugins%2Fcom.plexapp.plugins.animehd%2Fresources%2Fcover-default.jpg%3Ft%3D1415728749&urls=https%253A%2F%2Fstatic.hummingbird.me%2Fanime%2Fposter_images%2F000%2F007%2F000%2Flarge%2Fibn1YAUNCr0I4g.jpg%253F1416541456
2014-12-01 23:19:47,803 (10d4d6000) :  DEBUG (runtime:814) - Found route matching /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback
2014-12-01 23:19:47,804 (10d4d6000) :  DEBUG (networking:237) - Fetching HTTP headers for 'https://static.hummingbird.me/anime/poster_images/000/007/000/large/ibn1YAUNCr0I4g.jpg?1416541456'
2014-12-01 23:19:47,818 (10d8d9000) :  DEBUG (runtime:717) - Handling request GET /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback?fallback=%2F%3A%2Fplugins%2Fcom.plexapp.plugins.animehd%2Fresources%2Fcover-default.jpg%3Ft%3D1415728749&urls=https%253A%2F%2Fstatic.hummingbird.me%2Fanime%2Fposter_images%2F000%2F007%2F863%2Flarge%2FiDr2UPBEr4trZ.jpg%253F1416370892
2014-12-01 23:19:47,821 (10d8d9000) :  DEBUG (runtime:814) - Found route matching /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback
2014-12-01 23:19:47,822 (10d8d9000) :  DEBUG (networking:237) - Fetching HTTP headers for 'https://static.hummingbird.me/anime/poster_images/000/007/863/large/iDr2UPBEr4trZ.jpg?1416370892'
2014-12-01 23:19:47,828 (10c0c7000) :  DEBUG (runtime:106) - Sending packed state data (108 bytes)
2014-12-01 23:19:47,828 (10c0c7000) :  DEBUG (runtime:918) - Response: [302] Redirect, 0 bytes
2014-12-01 23:19:47,829 (10c0c7000) :  DEBUG (runtime:717) - Handling request GET /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback?fallback=%2F%3A%2Fplugins%2Fcom.plexapp.plugins.animehd%2Fresources%2Fcover-default.jpg%3Ft%3D1415728749&urls=https%253A%2F%2Fstatic.hummingbird.me%2Fanime%2Fposter_images%2F000%2F006%2F589%2Flarge%2FitJTVuFcCULzK.jpg%253F1416428763
2014-12-01 23:19:47,833 (10c0c7000) :  DEBUG (runtime:814) - Found route matching /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback
2014-12-01 23:19:47,834 (10c0c7000) :  DEBUG (networking:237) - Fetching HTTP headers for 'https://static.hummingbird.me/anime/poster_images/000/006/589/large/itJTVuFcCULzK.jpg?1416428763'
2014-12-01 23:19:47,839 (10c4ca000) :  DEBUG (runtime:106) - Sending packed state data (108 bytes)
2014-12-01 23:19:47,841 (10c4ca000) :  DEBUG (runtime:918) - Response: [302] Redirect, 0 bytes
2014-12-01 23:19:47,846 (10c8cd000) :  DEBUG (runtime:106) - Sending packed state data (108 bytes)
2014-12-01 23:19:47,846 (10c8cd000) :  DEBUG (runtime:918) - Response: [302] Redirect, 0 bytes
2014-12-01 23:19:47,911 (10c4ca000) :  DEBUG (runtime:717) - Handling request GET /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback?fallback=%2F%3A%2Fplugins%2Fcom.plexapp.plugins.animehd%2Fresources%2Fcover-default.jpg%3Ft%3D1415728749&urls=https%253A%2F%2Fstatic.hummingbird.me%2Fanime%2Fposter_images%2F000%2F008%2F607%2Flarge%2F47481d23jw1ejd2v508bpj20nk0xcwqx.jpg%253F1416323699
2014-12-01 23:19:47,913 (10c4ca000) :  DEBUG (runtime:814) - Found route matching /:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback
2014-12-01 23:19:47,914 (10c4ca000) :  DEBUG (networking:237) - Fetching HTTP headers for 'https://static.hummingbird.me/anime/poster_images/000/008/607/large/47481d23jw1ejd2v508bpj20nk0xcwqx.jpg?1416323699'
2014-12-01 23:19:47,918 (10d0d3000) :  DEBUG (runtime:106) - Sending packed state data (108 bytes)
2014-12-01 23:19:47,918 (10d0d3000) :  DEBUG (runtime:918) - Response: [302] Redirect, 0 bytes
2014-12-01 23:19:47,937 (10d4d6000) :  DEBUG (runtime:106) - Sending packed state data (108 bytes)
2014-12-01 23:19:47,937 (10d4d6000) :  DEBUG (runtime:918) - Response: [302] Redirect, 0 bytes
2014-12-01 23:19:47,948 (10d8d9000) :  DEBUG (runtime:106) - Sending packed state data (108 bytes)
2014-12-01 23:19:47,949 (10d8d9000) :  DEBUG (runtime:918) - Response: [302] Redirect, 0 bytes
2014-12-01 23:19:47,968 (10c0c7000) :  DEBUG (runtime:106) - Sending packed state data (108 bytes)
2014-12-01 23:19:47,968 (10c0c7000) :  DEBUG (runtime:918) - Response: [302] Redirect, 0 bytes
2014-12-01 23:19:48,024 (10c4ca000) :  DEBUG (runtime:106) - Sending packed state data (108 bytes)
2014-12-01 23:19:48,024 (10c4ca000) :  DEBUG (runtime:918) - Response: [302] Redirect, 0 bytes

When using Resource.ContentsOfURLWithFallback, you do not need to use R() in the fallback parameter.

COVER = 'icon-default.jpg'

thumb = Resource.ContentsOfURLWithFallback(url = cover, fallback = COVER)

When using Resource.ContentsOfURLWithFallback, you do not need to use R() in the fallback parameter.

COVER = 'icon-default.jpg'

thumb = Resource.ContentsOfURLWithFallback(url = cover, fallback = COVER)

Thanks but that still doesn't fix the issue why it's returning 0 bytes from the url, the fallback will never be used because it thinks it grabbed the picture but it's actually a 0 bytes picture resulting in displaying nothing.

The 0 bytes log line is from the redirect from the Plex Media Server URL (/:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback?....etc.) to the real image URL. A redirect http request doesn't contain a body, that's why it's 0 bytes. That is normal behaviour.

I think the issue could be that the redirect goes from http (local PMS) to https. Can you please try and see if it works if you replace https with http in your channel code?

cover = anime['mal_image'].replace('https://', 'http://')

The 0 bytes log line is from the redirect from the Plex Media Server URL (/:/plugins/com.plexapp.plugins.animehd/resources/contentWithFallback?....etc.) to the real image URL. A redirect http request doesn't contain a body, that's why it's 0 bytes. That is normal behaviour.

I think the issue could be that the redirect goes from http (local PMS) to https. Can you please try and see if it works if you replace https with http in your channel code?

cover = anime['mal_image'].replace('https://', 'http://')

Replacing https with http worked thanks a lot!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.