def handle_data(self, data): if self.get_date: temp = data temp = temp.replace("/"," ") temp = temp.replace(":"," ") values = temp.split(" ") self.date_day = int(values[0]) self.date_month = int(values[1]) self.date_year = int(values[2]) self.date_hour = int(values[3]) self.date_minute = int(values[4]) self.get_date = False self.searching_td_seeds = True elif self.get_downloads or self.search_downloads: self.downloads = int(data) self.get_downloads = False self.search_downloads = False self.searching_tr = True if common.terms_match(self.title,self.search_terms): self.dict["ai"+str(self.cont)] = {} self.dict["ai"+str(self.cont)]["title"] = self.title self.dict["ai"+str(self.cont)]["link"] = self.link self.dict["ai"+str(self.cont)]["date"] = datetime.datetime(self.date_year, self.date_month, self.date_day, self.date_hour, self.date_minute) self.dict["ai"+str(self.cont)]["downloads"] = self.downloads self.cont+=1 self.title = "" self.link = "" self.date_year = 0 self.date_month = 0 self.date_day = 0 self.date_hour = 0 self.date_minute = 0 self.downloads = 0
def handle_data(self, data): if self.searching_title: self.title = data elif self.searching_size_date and data.find("Size: ") != -1: temp = data date = temp[temp.find("Date: ") + 6:] date = date[:date.find(" UTC")] self.date_year = int(date[:date.find("-")]) date = date[date.find("-") + 1:] self.date_month = int(date[:date.find("-")]) date = date[date.find("-") + 1:] self.date_day = int(date[:date.find(" ")]) date = date[date.find(" ") + 1:] self.date_hour = int(date[:date.find(":")]) self.date_minute = int(date[date.find(":") + 1:]) self.searching_size_date = False if common.terms_match(self.title, self.search_terms): self.dict["t" + str(self.cont)] = {} self.dict["t" + str(self.cont)]["title"] = self.title self.dict["t" + str(self.cont)]["link"] = self.link self.dict["t" + str(self.cont)]["date"] = datetime.datetime( self.date_year, self.date_month, self.date_day, self.date_hour, self.date_minute) self.cont += 1 self.title = "" self.link = "" self.date_year = 0 self.date_month = 0 self.date_day = 0 self.date_hour = 0 self.date_minute = 0
def handle_data(self, data): if self.searching_title: self.title = data elif self.searching_size_date and data.find("Size: ")!=-1: temp = data date = temp[temp.find("Date: ")+6:] date = date[:date.find(" UTC")] self.date_year = int(date[:date.find("-")]) date = date[date.find("-")+1:] self.date_month = int(date[:date.find("-")]) date = date[date.find("-")+1:] self.date_day = int(date[:date.find(" ")]) date = date[date.find(" ")+1:] self.date_hour = int(date[:date.find(":")]) self.date_minute = int(date[date.find(":")+1:]) self.searching_size_date = False if common.terms_match(self.title,self.search_terms): self.dict["t"+str(self.cont)] = {} self.dict["t"+str(self.cont)]["title"] = self.title self.dict["t"+str(self.cont)]["link"] = self.link self.dict["t"+str(self.cont)]["date"] = datetime.datetime(self.date_year, self.date_month, self.date_day, self.date_hour, self.date_minute) self.cont+=1 self.title = "" self.link = "" self.date_year = 0 self.date_month = 0 self.date_day = 0 self.date_hour = 0 self.date_minute = 0
def __parse_rss(xml, dic, search_terms): if xml is not "": try: cont = 0 xml = xml.encode("utf8", "ignore") rss = XMLParser.fromstring(xml) channel = rss[0] for item in channel.findall('item'): title = item.find('title').text link = item.find('link').text date = item.find('pubDate').text date_parsed = datetime.strptime( date, "%a, %d %b %Y %H:%M:%S +0000") description = item.find('description').text values = [ int(s) for s in description.split() if s.isdigit() ] # TODO: use seeders/leechers seeders = values[0] # not yet used... leechers = values[1] # not yet used... downloads = values[2] if common.terms_match(title, search_terms): dic["n" + str(cont)] = {} dic["n" + str(cont)]["title"] = title dic["n" + str(cont)]["link"] = link dic["n" + str(cont)]["date"] = date_parsed dic["n" + str(cont)]["downloads"] = downloads cont += 1 # TODO: check all exceptions possible instead of just "Exception" except: pass return dic
def __parse_rss(xml, dic, search_terms): if xml is not "": try: cont = 0 xml = xml.encode("utf8","ignore") rss = XMLParser.fromstring(xml) channel = rss[0] for item in channel.findall('item'): title = item.find('title').text link = item.find('link').text date = item.find('pubDate').text date_parsed = datetime.strptime(date,"%a, %d %b %Y %H:%M:%S +0000") description = item.find('description').text values = [int(s) for s in description.split() if s.isdigit()] # TODO: use seeders/leechers seeders = values[0] # not yet used... leechers= values[1] # not yet used... downloads=values[2] if common.terms_match(title,search_terms): dic["n"+str(cont)] = {} dic["n"+str(cont)]["title"] = title dic["n"+str(cont)]["link"] = link dic["n"+str(cont)]["date"] = date_parsed dic["n"+str(cont)]["downloads"] = downloads cont+=1 # TODO: check all exceptions possible instead of just "Exception" except: pass return dic
def start_a(self, data): if self.get_link: for atrib,value in data: if atrib=="href": self.link = value self.get_link = False if common.terms_match(self.title,self.search_terms): self.dict["n"+str(self.cont)] = {} self.dict["n"+str(self.cont)]["title"] = self.title self.dict["n"+str(self.cont)]["link"] = self.link self.dict["n"+str(self.cont)]["date"] = None self.dict["n"+str(self.cont)]["downloads"] = self.downloads raise CleanExit
def start_a(self, data): if self.get_link: for atrib, value in data: if atrib == "href": self.link = value self.get_link = False if common.terms_match(self.title, self.search_terms): self.dict["n" + str(self.cont)] = {} self.dict["n" + str(self.cont)]["title"] = self.title self.dict["n" + str(self.cont)]["link"] = self.link self.dict["n" + str(self.cont)]["date"] = None self.dict["n" + str(self.cont)]["downloads"] = self.downloads raise CleanExit
def handle_data(self, data): if self.get_downloads: self.downloads = int(data) self.get_downloads = False if common.terms_match(self.title,self.search_terms): self.dict["ar"+str(self.cont)] = {} self.dict["ar"+str(self.cont)]["title"] = self.title self.dict["ar"+str(self.cont)]["link"] = self.link self.dict["ar"+str(self.cont)]["date"] = None self.dict["ar"+str(self.cont)]["downloads"] = self.downloads self.cont+=1 self.title = "" self.link = "" self.downloads = 0 self.searching_td_title = True
def handle_data(self, data): if self.get_title: self.title = data self.get_title = False self.searching_link = True elif self.confirmTorrent: temp = data if temp == "Torrent": self.searching_link = False self.confirmTorrent = False if common.terms_match(self.title, self.search_terms): self.dict["at" + str(self.cont)] = {} self.dict["at" + str(self.cont)]["title"] = self.title self.dict["at" + str(self.cont)]["link"] = self.link self.dict["at" + str(self.cont)]["date"] = None self.cont += 1 self.title = "" self.link = "" self.searching_div_title = True
def handle_data(self, data): if self.get_date: temp = data temp = temp.replace("/", " ") temp = temp.replace(":", " ") values = temp.split(" ") self.date_day = int(values[0]) self.date_month = int(values[1]) self.date_year = int(values[2]) self.date_hour = int(values[3]) self.date_minute = int(values[4]) self.get_date = False self.searching_td_seeds = True elif self.get_downloads or self.search_downloads: self.downloads = int(data) self.get_downloads = False self.search_downloads = False self.searching_tr = True if common.terms_match(self.title, self.search_terms): self.dict["ai" + str(self.cont)] = {} self.dict["ai" + str(self.cont)]["title"] = self.title self.dict["ai" + str(self.cont)]["link"] = self.link self.dict["ai" + str(self.cont)]["date"] = datetime.datetime( self.date_year, self.date_month, self.date_day, self.date_hour, self.date_minute) self.dict["ai" + str(self.cont)]["downloads"] = self.downloads self.cont += 1 self.title = "" self.link = "" self.date_year = 0 self.date_month = 0 self.date_day = 0 self.date_hour = 0 self.date_minute = 0 self.downloads = 0