Some of the URLs I get access to with my IGN plugin return HTTP 301 Response Status (Moved Permanently). This causes Plex to show the “Error while opening file” message. Has anyone run into this? Some of my stuff works and some doesn’t, and the difference seems to be the 200 vs 301 response. I don’t know if I’d call this a bug, but it could be something that was overlooked. I upgraded to Framework 2.0 but no difference.
Page I parse: http://video.ign.com
Examples of 2 URLs under Top Videos:
http://www.ign.com/videos/2010/09/15/devil-may-cry-debut-trailer (200, works)
http://gear.ign.com/dor/objects/64989/sony-move/videos/move_vdr_090110.html (301, doesn’t work)
I haven’t tried a workaround yet, which if even possible (I think it would be) would require pre-loading pages in advance to get their real URL. :unsure:
Well, I implemented a workaround. I’m no Python expert so this was cobbled together from what I found online, but it works.
<br />
#import urllib2<br />
<br />
class GetRedirectLocation(urllib2.HTTPRedirectHandler):<br />
def http_error_301(self, req, fp, code, msg, headers):<br />
return headers.get("Location")<br />
<br />
def GetRedirectIfPresent(url):<br />
req = urllib2.Request(url)<br />
opener = urllib2.build_opener(GetRedirectLocation())<br />
redirect = opener.open(req)<br />
<br />
if isinstance(redirect, str): # If not a 301 it won't hit the custom function above and will return a normal response object<br />
return redirect<br />
<br />
return url<br />
Not sure of the best solution, but just an FYI that I had a similar issue and found this link useful:
http://forums.plexapp.com/index.php/topic/17538-callback-for-media-items/page__p__105701__hl__redirect__fromsearch__1#entry105701
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.