Exemplo n.º 1
0
    def all_check(self):
        live = []
        try:
            for batch in self.batches:
                res = batch.check()
                if res:
                    live.extend(res)

            for one in self.onebyone:
                for url in one.url_list:

                    if one('检测' + url, url).check_stream():
                        live.append(url)

                    if url != one.url_list[-1]:
                        logger.debug('歇息会')
                        time.sleep(15)
        except IOError:
            logger.exception("IOError")
        finally:
            event_t = Event(TO_MODIFY)
            event_t.args = (live,)
            event_u = Event(UPLOAD)
            event_u.args = (live,)
            return event_u, event_t
Exemplo n.º 2
0
 def free_upload(self, _urls):
     logger.debug(_urls)
     event = []
     for title, v in engine.links_id.items():
         url = v[0]
         if self.free(v) and Upload(title).filter_file():
             event_d = Event(DOWNLOAD_UPLOAD)
             event_d.args = (title, url, 'up')
             event.append(event_d)
             # self.event_manager.send_event(event_d)
             self.url_status[url] = 2
     return tuple(event)
Exemplo n.º 3
0
    def free_upload(self, _urls):
        logger.debug(_urls)
        event = []
        for title, v in engine.links_id.items():
            # names = list(map(find_name, urls))
            url = v[0]
            # if title not in names and url_status[url] == 0 and Upload(title, url).filter_file():
            if self.free(v) and Upload(title).filter_file():
                event_d = Event(DOWNLOAD_UPLOAD)
                event_d.args = (title, url, 'up')
                event.append(event_d)

                # self.event_manager.send_event(event_d)
                self.url_status[url] = 2
                # print('up')
        return tuple(event)
Exemplo n.º 4
0
def process(name, url, mod):
    try:
        now = common.time_now()
        if mod == 'dl':
            p = multiprocessing.Process(target=download, args=(name, url))
            p.start()
            p.join()
            # download(name, url)
            Upload(name).start(url, now)
        elif mod == 'up':
            Upload(name).start(url, now)
        else:
            return url
    finally:
        event = Event(BE_MODIFIED)
        event.args = (url, )
        return event
Exemplo n.º 5
0
    def modify(self, live_m):
        live_d = {}
        if live_m:
            event = []
            for live in live_m:
                if self.url_status[live] == 1:
                    logger.debug('已开播正在下载')
                else:
                    name = engine.find_name(live)
                    logger.debug(name + '刚刚开播,去下载')
                    event_d = Event(DOWNLOAD_UPLOAD)
                    event_d.args = (name, live, 'dl')
                    event.append(event_d)

                live_d[live] = 1
            self.url_status.update(live_d)
            # url_status = {**url_status_base, **live_d}
            return tuple(event)

        else:
            logger.debug('无人直播')