From 29beeba864a4c4e96ea380488df4c74964abd491 Mon Sep 17 00:00:00 2001 From: Pedro de Oliveira Date: Tue, 3 Mar 2015 12:18:30 +0000 Subject: [PATCH] fix download of items that dont have subtitles --- rtp.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rtp.py b/rtp.py index 68c8f97..2f024c7 100755 --- a/rtp.py +++ b/rtp.py @@ -76,6 +76,7 @@ while True: for item in items: if exists >= 5: sys.exit("A sair apos 5 falhas, ja devo ter tudo...") + # url link = item.find('a') # data @@ -90,9 +91,13 @@ while True: # parte ? pts = item.findAll('b',{'class': 'text-dark-gray'}) - pt = pts[1].contents[0] - pt = pt.replace('...', '').strip() - pt = pt.replace(' ', '_') + try: + pt = pts[1].contents[0] + pt = pt.replace('...', '').strip() + pt = pt.replace(' ', '_') + pt = pt.replace('\n','') + except IndexError: + pt = "" print "-- " + dt, pt