{"action":"created","issue":{"url":"https://api.github.com/repos/learningit/plugin.video.cbc/issues/1","labels_url":"https://api.github.com/repos/learningit/plugin.video.cbc/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/learningit/plugin.video.cbc/issues/1/comments","events_url":"https://api.github.com/repos/learningit/plugin.video.cbc/issues/1/events","html_url":"https://github.com/learningit/plugin.video.cbc/issues/1","id":69134258,"number":1,"title":"IndexError in a[\"entries\"][0][\"media$content\"][0][\"plfile$downloadUrl\"]","user":{"login":"brianjmurrell","id":559317,"avatar_url":"https://avatars.githubusercontent.com/u/559317?v=3","gravatar_id":"","url":"https://api.github.com/users/brianjmurrell","html_url":"https://github.com/brianjmurrell","followers_url":"https://api.github.com/users/brianjmurrell/followers","following_url":"https://api.github.com/users/brianjmurrell/following{/other_user}","gists_url":"https://api.github.com/users/brianjmurrell/gists{/gist_id}","starred_url":"https://api.github.com/users/brianjmurrell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianjmurrell/subscriptions","organizations_url":"https://api.github.com/users/brianjmurrell/orgs","repos_url":"https://api.github.com/users/brianjmurrell/repos","events_url":"https://api.github.com/users/brianjmurrell/events{/privacy}","received_events_url":"https://api.github.com/users/brianjmurrell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-04-17T12:59:40Z","updated_at":"2015-04-17T16:45:00Z","closed_at":null,"body":"Hi,\r\n\r\nI am using your plugin -- great work BTW -- and I got this error:\r\n\r\n```\r\nTraceback (most recent call last):\r\n...\r\n  File \"/home/mythtv/.kodi/addons/plugin.video.cbc/default.py\", line 212, in getLink\r\n    u = a[\"entries\"][0][\"media$content\"][0][\"plfile$downloadUrl\"]\r\nIndexError: list index out of range\r\n```\r\n\r\nPresumably it means that the data that is returned in the ```getLink()``` is incomplete or bad in some way.\r\n\r\nWhen this happens, it would be most interesting to see the contents of ```a``` don't you think?\r\n\r\nI am not a Kodi [plugin] developer so I'm not sure what the best way to go about doing that.  Perhaps your ```log``` function is the best way.  But I am also not sure the correct way to inform Kodi about the failure rather than the successful case of using ```xbmcplugin.setResolvedUrl```\r\n\r\nSomething like:\r\n\r\n```\r\ntry:\r\n    u = a[\"entries\"][0][\"media$content\"][0][\"plfile$downloadUrl\"]\r\nexcept IndexError:\r\n    log(\"got an index error trying to get a[\\\"entries\\\"][0][\\\"media$content\\\"][0][\\\"plfile$downloadUrl\\\"] out of %s\" % a)\r\n    # inform Kodi and get out of here\r\n\r\n```\r\n\r\nin ```getLink()``` rather than just the:\r\n\r\n```\r\nu = a[\"entries\"][0][\"media$content\"][0][\"plfile$downloadUrl\"]\r\n```\r\n\r\nperhaps?  Sorry about the format above rather than a patch.  I'm not working in a git repo and am just hacking up the live file as I go."},"comment":{"url":"https://api.github.com/repos/learningit/plugin.video.cbc/issues/comments/94024608","html_url":"https://github.com/learningit/plugin.video.cbc/issues/1#issuecomment-94024608","issue_url":"https://api.github.com/repos/learningit/plugin.video.cbc/issues/1","id":94024608,"user":{"login":"brianjmurrell","id":559317,"avatar_url":"https://avatars.githubusercontent.com/u/559317?v=3","gravatar_id":"","url":"https://api.github.com/users/brianjmurrell","html_url":"https://github.com/brianjmurrell","followers_url":"https://api.github.com/users/brianjmurrell/followers","following_url":"https://api.github.com/users/brianjmurrell/following{/other_user}","gists_url":"https://api.github.com/users/brianjmurrell/gists{/gist_id}","starred_url":"https://api.github.com/users/brianjmurrell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianjmurrell/subscriptions","organizations_url":"https://api.github.com/users/brianjmurrell/orgs","repos_url":"https://api.github.com/users/brianjmurrell/repos","events_url":"https://api.github.com/users/brianjmurrell/events{/privacy}","received_events_url":"https://api.github.com/users/brianjmurrell/received_events","type":"User","site_admin":false},"created_at":"2015-04-17T16:45:00Z","updated_at":"2015-04-17T16:45:00Z","body":"> Could you post the log to either xbmclogs.com or pastebin.com ?\r\n\r\nI'm not actually using your plugin in Kodi.  :-)  I have another project where my interest is in downloading the episode, not actually watching it streaming.  So I wrote my own tool and stubbed out the xbmc functions.  Apart from this Index Error it seems to work well.\r\n\r\nOn that topic, I had wondered how receptive you'd be to separating out the website scraping from the XBMC/Kodi presentation so that the website scraping could be used in other projects.  :-)\r\n\r\n> I tend not to wrap statements like this with a try-except unless I know that there is a chance of failure.\r\n\r\nRight.  But clearly there is in this case.\r\n\r\n> Doing so masks problems\r\n\r\nIt only masks them if you pass on the exception.  If you use the exception to handle the error nothing gets masked and the exceptional situation gets handled.\r\n\r\n> which need to be looked into and there's rarely an elegant and complete way to recover from this type of an error - but that's just kind of a personal choice.\r\n\r\nAt minimum we could log the data that caused the problem such as I did in my example.\r\n\r\n> This particular website occasionally suffers from internal errors where it either doesn't return data or the connection times out.\r\n\r\nSo some retry logic might be necessary.\r\n\r\n> I'd really like to see the log so I can figure out what's going on\r\n\r\nAs above, there is no log per se.\r\n\r\n> I had a further look at this and I will probably leave it they way it is.\r\n\r\nYou are not even interested in why an Index Error can happen here?\r\n\r\n> A script error will be reported by Kodi when it occurs and the full debug data will be in the log.\r\n\r\nWill the content scraped from the website be in the log in the same was as my patch makes it available?\r\n\r\n> The script terminates on error so setResolvedUrl will not execute.\r\n\r\nRight, but it leaves Kodi and the user kind of wondering what went wrong.\r\n\r\n> From the end user perspective, the url failed to play and whether I tell them that it's an index error or Kodi reports a script error is moot.\r\n\r\nSure, but the important part is logging what the script scraped from the website that caused the error."}}