diff --git a/netflix.py b/netflix.py index cf0455d..866765a 100644 --- a/netflix.py +++ b/netflix.py @@ -125,11 +125,29 @@ def getTitle(self): s = self.soupObject.find("meta", attrs={"name": "twitter:title"}) self.title = str(s['content']) self.title = self.title.strip() + temp_title = self.title.split() + if temp_title[0]=='Watch' or temp[0] == "watch": + self.title = ' '.join(self.title.split()[1:]) + self.title = self.title.replace(" Online | Netflix","") if not self.title: s = int("deliberateError") except: - self.title = "Netflixsubtitles" + + try: + # + s = self.soupObject.find("meta", attrs={"property": "og:title"}) + self.title = str(s['content']) + self.title = self.title.strip() + temp_title = self.title.split() + if temp_title[0]=='Watch' or temp[0] == "watch": + self.title = ' '.join(self.title.split()[1:]) + self.title = self.title.replace(" Online | Netflix","") + if not self.title: + s = int("deliberateError") + + except: + self.title = "Netflixsubtitles" pass diff --git a/newamazon.py b/newamazon.py index bd20938..0463053 100644 --- a/newamazon.py +++ b/newamazon.py @@ -335,7 +335,9 @@ def getTitle(self): """ This function returns the title of the video. This is also used for naming the file. - --> Extracting the value from here + --> Extracting the value from here + OR + --> Extracting the value from here """ @@ -344,13 +346,31 @@ def getTitle(self): s = self.soupObject.find("meta", attrs={"name": "twitter:title"}) self.title = str(s['content']) self.title = self.title.replace("/", "") + temp_title = self.title.split() + if temp_title[0]=='Watch' or temp[0] == "watch": + self.title = ' '.join(self.title.split()[1:]) + self.title = self.title.replace("- Amazon Video","") self.title = self.title.strip() if not self.title: s = int("deliberateError") # except except: - self.title = "Amazonsubtitles" + + try: + s = self.soupObject.find("meta", attrs={"property": "og:title"}) + self.title = str(s['content']) + self.title = self.title.replace("/", "") + temp_title = self.title.split() + if temp_title[0]=='Watch' or temp[0] == "watch": + self.title = ' '.join(self.title.split()[1:]) + self.title = self.title.replace("- Amazon Video","") + self.title = self.title.strip() + if not self.title: + s = int("deliberateError") + + except: + self.title = "Amazonsubtitles" pass @@ -388,4 +408,4 @@ def standardFunctionCalls(self): self.deleteUnnecessaryfiles() return returnValue - pass \ No newline at end of file + pass