Ejemplo n.º 1
0
    def run(self):
        self.links = []
        self.updates = {}

        while len(self.db) > 0:

            # get an unchecked series
            try:
                job_lock.acquire()
                if len(self.db) > 0:
                    series, val = self.db.popitem()
                else:
                    break
            finally:
                job_lock.release()

            url, pattern, last = val[0], val[1], val[2]

            job_lock.acquire()
            print "checking", series + "..."
            job_lock.release()

            # try get the online feeds
            feeds = fetch(url, pattern, retry_num=7)

            if (feeds):  # if success
                n = 0

                # check whether new links exist
                while (n < len(feeds) and feeds[n]['name'] != last):
                    self.links.append((series, feeds[n]['name'],
                                       feeds[n]['link'], feeds[n]['date']))
                    n = n + 1

                if (n != 0):
                    self.updates[series] = [None, None, feeds[0]['name']]

                    job_lock.acquire()
                    print n, "updates found for", series, ":"
                    for i in range(n):
                        print "    +", feeds[i]['name']

                    job_lock.release()
                else:
                    print "no update found for", series

            else:  # if not success after several retry

                # assume unchecked
                job_lock.acquire()
                print "connection error on checking {0}, retrying later".format(
                    series)
                self.db[series] = val
                job_lock.release()
Ejemplo n.º 2
0
	def run(self):
		self.links = []
		self.updates = {}
		
		while len(self.db) > 0:
			
			# get an unchecked series
			try:
				job_lock.acquire()
				if len(self.db) > 0: 
					series, val = self.db.popitem()
				else: break
			finally:
				job_lock.release()
			
			url, pattern, last = val[0], val[1], val[2]
			
			job_lock.acquire()
			print "checking", series + "..."
			job_lock.release()
			
			# try get the online feeds
			feeds = fetch(url, pattern, retry_num=7)
			
			
			if (feeds): # if success
				n = 0
				
				# check whether new links exist
				while(n < len(feeds) and feeds[n]['name'] != last):
					self.links.append((series, feeds[n]['name'], feeds[n]['link'], feeds[n]['date']))
					n = n + 1
							
				if (n != 0):
					self.updates[series] = [None, None, feeds[0]['name']]
					
					job_lock.acquire()
					print n, "updates found for", series, ":"
					for i in range(n):
						print "    +", feeds[i]['name']
						
					job_lock.release()
				else:
					print "no update found for", series
					
			else: # if not success after several retry
			
				# assume unchecked
				job_lock.acquire()
				print "connection error on checking {0}, retrying later".format(series)
				self.db[series] = val
				job_lock.release()
Ejemplo n.º 3
0
	def run(self):
		self.links = []
		self.updates = {}
		
		for series, val in self.db.items():
			url, pattern, last = val[0], val[1], val[2]

			feeds = fetch(url, pattern)
			
			if (feeds):
				n = 0
				while(n < len(feeds) and feeds[n]['name'] != last):
					self.links.append((series, feeds[n]['name'], feeds[n]['link'], feeds[n]['date']))
					n = n + 1
							
				if (n != 0):
					self.updates[series] = [None, None, feeds[0]['name']]
Ejemplo n.º 4
0
    def run(self):
        self.links = []
        self.updates = {}

        for series, val in self.db.items():
            url, pattern, last = val[0], val[1], val[2]

            feeds = fetch(url, pattern)

            if (feeds):
                n = 0
                while (n < len(feeds) and feeds[n]['name'] != last):
                    self.links.append((series, feeds[n]['name'],
                                       feeds[n]['link'], feeds[n]['date']))
                    n = n + 1

                if (n != 0):
                    self.updates[series] = [None, None, feeds[0]['name']]
Ejemplo n.º 5
0
def checkUpdate(res):
	links = []
	updates = {}
	for key, val in res.items():
		ret = fetch(val[0], val[1])
		if (ret):
			n = 0
			while(n < len(ret) and ret[n]['name'] != val[2]):
				links.append((ret[n]['link'], ret[n]['name'] + ".torrent"))
				n = n + 1
			if (n == 0): print key, "is already updated"
			else:
				updates[key] = [None, None, ret[0]['name']]
				print key, "has", n, "new update(s)!"
				for i in range(n): print ret[i]['name']
		else:
			print "Connection error on checking", key
		print
Ejemplo n.º 6
0
def checkUpdate(res):
    links = []
    updates = {}
    for key, val in res.items():
        ret = fetch(val[0], val[1])
        if (ret):
            n = 0
            while (n < len(ret) and ret[n]['name'] != val[2]):
                links.append((ret[n]['link'], ret[n]['name'] + ".torrent"))
                n = n + 1
            if (n == 0): print key, "is already updated"
            else:
                updates[key] = [None, None, ret[0]['name']]
                print key, "has", n, "new update(s)!"
                for i in range(n):
                    print ret[i]['name']
        else:
            print "Connection error on checking", key
        print