def process_telegram_data(self, data, target=None):
     try:
         ret = ModelBotDownloaderKtvItem.process_telegram_data(data)
         #logger.debug(ret)
         if ret is not None:
             if ModelSetting.get_bool('receive_info_send_telegram'):
                 msg = '😉 TV 정보 수신\n'
                 msg += '제목 : %s\n' % data['filename']
                 if ret is None:
                     msg += '중복 마그넷입니다.'
                     #TelegramHandle.sendMessage(msg)
                 else:
                     url = '%s/%s/api/%s/add_download?url=%s' % (SystemModelSetting.get('ddns'), package_name, self.name, ret.magnet)
                     if SystemModelSetting.get_bool('auth_use_apikey'):
                         url += '&apikey=%s' % SystemModelSetting.get('auth_apikey')
                     if app.config['config']['is_sjva_server']:
                         msg += '\n' + ret.magnet + '\n'
                     else:
                         msg += '\n➕ 다운로드 추가\n<%s>\n' % url
                     try:
                         if ret.daum_id is not None:
                             url = 'https://search.daum.net/search?w=tv&q=%s&irk=%s&irt=tv-program&DA=TVP' % (urllib.quote(ret.daum_title.encode('utf8')), ret.daum_id)
                             msg += '\n● Daum 정보\n%s' % url
                     except Exception as e: 
                         logger.error('Exception:%s', e)
                         logger.error(traceback.format_exc())  
                 import framework.common.notify as Notify
                 Notify.send_message(msg, image_url=ret.daum_poster_url, message_id='bot_downloader_ktv_receive')
             self.invoke()
             TorrentProcess.receive_new_data(ret, package_name)
     except Exception, e:
             logger.error('Exception:%s', e)
             logger.error(traceback.format_exc())
Пример #2
0
    def scheduler_function_task():
        try:
            logger.debug('RSS scheduler_function')
            items = ModelScheduler2.get_list()
            for item in items:
                logger.debug(u'스케쥴링 시작')
                logger.debug('%s %s', item.sitename, item.board_id)
                if item.site is None:
                    continue
                if not item.include_scheduler:
                    logger.debug('not include_scheduler')
                    continue

                if 'USING_BOARD_CHAR_ID' not in item.site.info['EXTRA']:
                    last_bbs = item.get_last_bbs()
                    if last_bbs is not None:
                        max_id = last_bbs.board_id
                    else:
                        max_id = 0
                else:
                    max_id = 0
                rss_list = LogicFromSite.get_list(
                    item.site,
                    item.board_id,
                    max_id=max_id,
                    page=ModelSetting.get_int('max_page'),
                    scheduler_instance=item)
                if rss_list:
                    save_list = LogicSelf.__db_save_list(
                        item.site, item, rss_list)
                    #logger.debug(save_list)

                    groups = LogicSelf.get_group_list()
                    group_name = None
                    for group in groups:
                        for sched in group['schedulers']:
                            if sched['sitename'] == item.sitename and sched[
                                    'board_id'] == item.board_id:
                                group_name = group['groupname']
                                break
                        if group_name is not None:
                            break

                    from framework.common.torrent.process import TorrentProcess
                    TorrentProcess.server_process(save_list,
                                                  category=group_name)

            # selenium이 celery에서 돌 경우 해제안됨.
            from system import SystemLogicSelenium
            SystemLogicSelenium.close_driver()

        except Exception as e:
            logger.error('Exception:%s', e)
            logger.error(traceback.format_exc())
Пример #3
0
    def process_telegram_data(data):
        try:
            ret = ModelMovieItem.process_telegram_data(data)
            #logger.debug('telegram bot receive. is exist : %s', ret)
            if ret is not None:
                if ModelSetting.get_bool('receive_info_send_telegram'):
                    msg = '😉 영화 정보 수신\n'
                    msg += '제목 : %s (%s)\n' % (ret.movie_title, ret.movie_year)
                    msg += '파일 : %s\n' % ret.filename
                    url = '%s/%s/api/add_download?id=%s' % (
                        SystemModelSetting.get('ddns'), package_name, ret.id)
                    if SystemModelSetting.get_bool('auth_use_apikey'):
                        url += '&apikey=%s' % SystemModelSetting.get(
                            'auth_apikey')
                    if app.config['config']['is_sjva_server']:
                        msg += '\n' + ret.magnet + '\n'
                    else:
                        msg += '\n➕ 다운로드 추가\n<%s>\n' % url
                    #msg += '\n➕ 다운로드 추가\n<%s>\n' % url
                    try:
                        if ret.movie_title is not None:
                            if ret.movie_target == 'imdb':
                                url = 'https://www.imdb.com/title/%s' % ret.movie_id
                                msg += '\n● IMDB 정보\n%s' % url
                            else:
                                url = 'https://movie.daum.net/moviedb/main?movieId=%s' % (
                                    ret.movie_id)
                                msg += '\n● Daum 정보\n%s' % url
                    except Exception as e:
                        logger.error('Exception:%s', e)
                        logger.error(traceback.format_exc())

                    import framework.common.notify as Notify
                    Notify.send_message(
                        msg,
                        image_url=ret.daum_poster,
                        message_id='bot_downloader_movie_receive')
                LogicNormal.invoke()
                TorrentProcess.receive_new_data(ret, package_name)
        except Exception, e:
            logger.error('Exception:%s', e)
            logger.error(traceback.format_exc())
Пример #4
0
    def process_telegram_data(data):
        try:
            ret = ModelItem.process_telegram_data(data)
            logger.debug(data)
            #ret = None
            if ret is not None:
                if ModelSetting.get_bool('receive_send_notify'):
                    msg = '😉 AV 정보 수신\n'
                    msg += '제목 : [%s] %s (%s)\n' % (ret.code, ret.title,
                                                    ret.date)
                    msg += '파일 : %s\n' % ret.filename
                    msg += '폴더 : %s\n' % ret.dirname
                    msg += '크기 : %s\n' % Util.sizeof_fmt(ret.total_size)

                    url = '%s/%s/api/add_download?id=%s' % (
                        SystemModelSetting.get('ddns'), package_name, ret.id)
                    if SystemModelSetting.get_bool('auth_use_apikey'):
                        url += '&apikey=%s' % SystemModelSetting.get(
                            'auth_apikey')
                    if app.config['config']['is_sjva_server']:
                        msg += '\n' + ret.magnet + '\n'
                    else:
                        msg += '\n➕ 다운로드 추가\n<%s>\n' % url
                    #msg += '\n➕ 다운로드 추가\n<%s>\n' % url

                    poster = ret.poster if ModelSetting.get_bool(
                        'show_poster_notify') else None
                    import framework.common.notify as Notify
                    Notify.send_message(msg,
                                        image_url=poster,
                                        message_id='bot_downloader_av_receive')
                LogicNormal.invoke()
                TorrentProcess.receive_new_data(ret, package_name)
        except Exception, e:
            logger.error('Exception:%s', e)
            logger.error(traceback.format_exc())
Пример #5
0
def ajax(sub):
    try:
        ret = {}
        # self - setting
        if sub == 'setting_save':
            ret = ModelSetting.setting_save(request)
            return jsonify(ret)
        elif sub == 'scheduler':
            go = request.form['scheduler']
            logger.debug('scheduler :%s', go)
            if go == 'true':
                Logic.scheduler_start()
            else:
                Logic.scheduler_stop()
            return jsonify(go)
        elif sub == 'one_execute':
            ret = Logic.one_execute()
            return jsonify(ret)
        elif sub == 'reset_db':
            ret = Logic.reset_db()
            return jsonify(ret)

        # self - site
        elif sub == 'load_site':
            ret['site'] = ModelSite2.get_list(by_dict=True)
            return jsonify(ret)
        elif sub == 'test':
            ret = LogicSelf.action_test(request)
            return jsonify(ret)
        elif sub == 'site_delete':
            ret['ret'] = ModelSite2.delete(request.form['site_id'])
            ret['site'] = ModelSite2.get_list(by_dict=True)
            return jsonify(ret)
        elif sub == 'site_edit':
            ret['ret'] = LogicSelf.site_edit(request)
            ret['site'] = ModelSite2.get_list(by_dict=True)
            return jsonify(ret)

        # self - scheduler
        elif sub == 'load_scheduler':
            ret['site'] = ModelSite2.get_list(by_dict=True)
            ret['scheduler'] = LogicSelf.get_scheduler_list()
            return jsonify(ret)
        elif sub == 'add_scheduler':
            ret['ret'] = LogicSelf.add_scheduler(request)
            ret['site'] = ModelSite2.get_list(by_dict=True)
            ret['scheduler'] = LogicSelf.get_scheduler_list()
            return jsonify(ret)
        elif sub == 'remove_scheduler_db':
            ret['ret'] = LogicSelf.remove_scheduler_db_from_id(
                request.form['db_id'])
            ret['site'] = ModelSite2.get_list(by_dict=True)
            ret['scheduler'] = LogicSelf.get_scheduler_list()
            return jsonify(ret)
        elif sub == 'remove_scheduler':
            ret['ret'] = LogicSelf.remove_scheduler(request)
            ret['site'] = ModelSite2.get_list(by_dict=True)
            ret['scheduler'] = LogicSelf.get_scheduler_list()
            return jsonify(ret)

        # self - group
        elif sub == 'load_group':
            ret['site'] = ModelSite2.get_list(by_dict=True)
            ret['group'] = LogicSelf.get_group_list()
            ret['info'] = LogicSelf.get_search_form_info()
            return jsonify(ret)
        elif sub == 'add_group':
            ret['ret'] = LogicSelf.add_group(request)
            ret['site'] = ModelSite2.get_list(by_dict=True)
            ret['group'] = LogicSelf.get_group_list()
            ret['info'] = LogicSelf.get_search_form_info()
            return jsonify(ret)
        elif sub == 'remove_group':
            ret['ret'] = LogicSelf.remove_group(request)
            ret['site'] = ModelSite2.get_list(by_dict=True)
            ret['group'] = LogicSelf.get_group_list()
            ret['info'] = LogicSelf.get_search_form_info()
            return jsonify(ret)
        elif sub == 'add_group_child':
            ret['ret'] = LogicSelf.add_group_child(request)
            ret['site'] = ModelSite2.get_list(by_dict=True)
            ret['group'] = LogicSelf.get_group_list()
            ret['info'] = LogicSelf.get_search_form_info()
            return jsonify(ret)
        elif sub == 'remove_group_child':
            ret['ret'] = LogicSelf.remove_group_child(request)
            ret['site'] = ModelSite2.get_list(by_dict=True)
            ret['group'] = LogicSelf.get_group_list()
            ret['info'] = LogicSelf.get_search_form_info()
            return jsonify(ret)

        # self - search
        elif sub == 'list':
            ret = LogicSearchSelf.get_list_by_web(request)
            return jsonify(ret)

        # 토렌트 인포
        elif sub == 'torrent_info':
            try:
                from torrent_info import Logic as TorrentInfoLogic
                data = request.form['hash']
                logger.debug(data)
                if data.startswith('magnet'):
                    ret = TorrentInfoLogic.parse_magnet_uri(data)
                else:
                    ret = TorrentInfoLogic.parse_torrent_url(data)
                return jsonify(ret)
            except Exception as e:
                logger.error('Exception:%s', e)
                logger.error(traceback.format_exc())
        elif sub == 'server_test':
            logger.debug('server_test')
            from framework.common.torrent.process import TorrentProcess
            tmp = db.session.query(ModelBbs2).all()
            ret = TorrentProcess.server_process(tmp, category='AV')
            return jsonify(ret)

    except Exception as e:
        logger.error('Exception:%s', e)
        logger.error(traceback.format_exc())
        return jsonify('fail')