Merge lp:~jtatum/supytube/indexerrors into lp:supytube

Proposed by James Tatum
Status: Merged
Approved by: Benjamin Rubin
Approved revision: 10
Merged at revision: 10
Proposed branch: lp:~jtatum/supytube/indexerrors
Merge into: lp:supytube
Diff against target: 15 lines (+4/-1)
1 file modified
plugin.py (+4/-1)
To merge this branch: bzr merge lp:~jtatum/supytube/indexerrors
Reviewer Review Type Date Requested Status
Benjamin Rubin Approve
Review via email: mp+56292@code.launchpad.net

Description of the change

If youtube is mentioned in channel, IndexError is raised. Fix with try/except.

To post a comment you must log in.
Revision history for this message
Benjamin Rubin (bnrubin) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugin.py'
2--- plugin.py 2011-03-29 01:24:39 +0000
3+++ plugin.py 2011-04-05 06:01:30 +0000
4@@ -55,7 +55,10 @@
5 def getVideoid(self,msg):
6 for word in msg.args[1].split(' '):
7 if(word.find("youtube") != -1):
8- return urlparse(word.replace ('#!' , '?'))[4].split('=')[1].split('&')[0]
9+ try:
10+ return urlparse(word.replace ('#!' , '?'))[4].split('=')[1].split('&')[0]
11+ except IndexError:
12+ log.debug("Couldn't find youtube video ID in string: %s" % word)
13
14 def convertRating(self,oldrating):
15 return 100 * (float(oldrating)/5)

Subscribers

People subscribed via source and target branches

to all changes: