re1 = re.compile('MV: ' + titleRegex + weirdShitRegex) re2 = re.compile('RE: Rated (.*?) ' ) for line in ratingsFile: movieMatch = re1.match(line) if(movieMatch and movieMatch.group(1) and not movieMatch.group(2) and not movieMatch.group(3)): movie = movieMatch.group(1) movieFound = True continue ratingMatch = re2.match(line) if(ratingMatch and movieFound): rating = ratingMatch.group(1) try: if(movie in titles): s.addRating(movie, rating) #print movie + " ::: " + rating except: continue movieFound = False #--------------------------------------------------------------------------------------- #DURANTIONS durationsFile = open( PATH + DURATION_FILE ) regex = re.compile(titleRegex + weirdShitRegex + splitRegex + '(.*?:)?(\d*)')