Beispiel #1
0
def second_menu(sub, sub2):
    try:
        arg = ModelSetting.to_dict()
        arg['sub'] = sub
        job_id = '%s_%s' % (package_name, sub)
        if sub == 'download':
            if sub2 == 'setting':
                arg['scheduler'] = str(scheduler.is_include(job_id))
                arg['is_running'] = str(scheduler.is_running(job_id))
                return render_template('{package_name}_{sub}_{sub2}.html'.format(package_name=package_name, sub=sub, sub2=sub2), arg=arg)
            elif sub2 == 'list':
                return render_template('{package_name}_{sub}_{sub2}.html'.format(package_name=package_name, sub=sub, sub2=sub2), arg=arg)
        elif sub == 'subcat':
            logger.debug('SUB %s %s %s', package_name, sub, sub2)
            if sub2 == 'setting':
                arg['scheduler'] = str(scheduler.is_include(job_id))
                arg['is_running'] = str(scheduler.is_running(job_id))
                return render_template('{package_name}_{sub}_{sub2}.html'.format(package_name=package_name, sub=sub, sub2=sub2), arg=arg)
            elif sub2 == 'list':
                logger.debug('SUB %s %s %s', package_name, sub, sub2)
                return render_template('%s_%s_%s.html' % (package_name, sub, sub2), arg=arg)
        return render_template('sample.html', title='%s - %s' % (package_name, sub))
    except Exception as e:
        logger.error('Exception:%s', e)
        logger.error(traceback.format_exc())
Beispiel #2
0
    def one_execute():
        try:
            if scheduler.is_include(package_name):
                if scheduler.is_running(package_name):
                    ret = 'is_running'
                else:
                    scheduler.execute_job(package_name)
                    ret = 'scheduler'
            else:

                def func():
                    time.sleep(2)
                    Logic.scheduler_function()
                    Logic.job_thread = None

                if Logic.job_thread is None:
                    Logic.job_thread = threading.Thread(target=func, args=())
                    Logic.job_thread.start()
                    ret = 'thread'
                else:
                    ret = 'is_running'
        except Exception as e:
            logger.error('Exception:%s', e)
            logger.error(traceback.format_exc())
            ret = 'fail'
        return ret
Beispiel #3
0
def detail(sub):
    logger.debug('DETAIL %s %s', package_name, sub)
    if sub == 'setting':
        setting_list = db.session.query(ModelSetting).all()
        arg = Util.db_list_to_dict(setting_list)
        arg['scheduler'] = str(scheduler.is_include(package_name))
        arg['is_running'] = str(scheduler.is_running(package_name))
        arg['path_rclone'] = Logic.path_rclone
        arg['default_rclone_setting'] = Logic.default_rclone_setting
        return render_template('rclone_setting.html', sub=sub, arg=arg)
    elif sub == 'status':
        return render_template('rclone_status.html')
    elif sub == 'list':
        return render_template('rclone_list.html')
    elif sub == 'log':
        return render_template('log.html', package=package_name)
    elif sub == 'mount':
        return redirect('/%s/mount_setting' % package_name)
    elif sub == 'mount_setting':
        arg = {}
        arg['option'] = '--allow-other --fast-list --drive-skip-gdocs --poll-interval=1m --buffer-size=32M --vfs-read-chunk-size=32M --vfs-read-chunk-size-limit 2048M --vfs-cache-mode writes --dir-cache-time=1m --log-level INFO'
        #if platform.system() != 'Windows':
        #    arg['option'] += ' --daemon'
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub == 'serve_setting':
        arg = {}
        arg['option'] = '--user sjva --pass sjva --fast-list --drive-skip-gdocs --poll-interval=1m --buffer-size=32M --vfs-read-chunk-size=32M --vfs-read-chunk-size-limit 2048M --vfs-cache-mode writes --dir-cache-time=1m --log-level INFO'
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    else:
        return blueprint.send_static_file(sub)
    return render_template('sample.html',
                           title='%s - %s' % (package_name, sub))
 def process_menu(self, sub, req):
     arg = P.ModelSetting.to_dict()
     arg['sub'] = self.name
     if sub == 'setting':
         arg['scheduler'] = str(
             scheduler.is_include(self.get_scheduler_name()))
         arg['is_running'] = str(
             scheduler.is_running(self.get_scheduler_name()))
         arg['rss_api'] = '%s/%s/api/%s/rss' % (
             SystemModelSetting.get('ddns'), package_name, self.name)
         arg['rss_api'] = Util.make_apikey(arg['rss_api'])
         return render_template(
             '{package_name}_{module_name}_{sub}.html'.format(
                 package_name=package_name, module_name=self.name, sub=sub),
             arg=arg)
     elif sub == 'list':
         arg['is_torrent_info_installed'] = False
         try:
             import torrent_info
             arg['is_torrent_info_installed'] = True
         except:
             pass
         arg['ddns'] = SystemModelSetting.get('ddns')
         arg['show_log'] = ModelSetting.get_bool('show_log')
         arg['show_poster'] = ModelSetting.get('show_poster')
         return render_template(
             '{package_name}_{module_name}_{sub}.html'.format(
                 package_name=package_name, module_name=self.name, sub=sub),
             arg=arg)
     return render_template('sample.html',
                            title='%s - %s' % (package_name, sub))
Beispiel #5
0
def first_menu(sub):
    arg = ModelSetting.to_dict()
    arg['package_name'] = package_name
    if sub == 'setting':
        arg['scheduler'] = str(scheduler.is_include(package_name))
        arg['is_running'] = str(scheduler.is_running(package_name))
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub == 'request':
        arg['is_running'] = str(scheduler.is_running(package_name))
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub in ['queue', 'list']:
        return render_template('%s_%s.html' % (package_name, sub))
    elif sub == 'log':
        return render_template('log.html', package=package_name)
    return render_template('sample.html',
                           title='%s - %s' % (package_name, sub))
Beispiel #6
0
        def process_menu(self, sub, req):
            arg = P.ModelSetting.to_dict()
            arg['sub'] = self.name
            for key, value in list(arg.items()):
                if key.startswith(self.name):
                    arg[key.replace(self.name + '_', '')] = value
                    del arg[key]
            if sub in ['setting', 'request', 'queue', 'list']:
                if sub == 'setting':
                    job_id = '%s_%s' % (self.P.package_name, self.name)
                    arg['scheduler'] = str(scheduler.is_include(job_id))
                    arg['is_running'] = str(scheduler.is_running(job_id))
                elif sub == 'request':
                    if sub == 'request' and req.args.get(
                            'content_code') is not None:
                        arg['current_code'] = req.args.get('content_code')

                return render_template(
                    '{package_name}_{module_name}_{sub}.html'.format(
                        package_name=P.package_name,
                        module_name='toki',
                        sub=sub),
                    arg=arg)
            return render_template('sample.html',
                                   title='%s - %s' % (P.package_name, sub))
Beispiel #7
0
def first_menu(sub):
    logger.debug('DETAIL %s %s', package_name, sub)
    if sub == 'setting':
        arg = ModelSetting.to_dict()
        arg['package_name'] = package_name
        arg['scheduler'] = str(scheduler.is_include(package_name))
        arg['is_running'] = str(scheduler.is_running(package_name))
        from system.model import ModelSetting as SystemModelSetting
        ddns = SystemModelSetting.get('ddns')
        arg['rss_api'] = '%s/%s/api/rss' % (ddns, package_name)
        if SystemModelSetting.get_bool('auth_use_apikey'):
            arg['rss_api'] += '?apikey=%s' % SystemModelSetting.get(
                'auth_apikey')

        return render_template('%s_setting.html' % package_name,
                               sub=sub,
                               arg=arg)
    elif sub == 'list':
        arg = {'package_name': package_name}
        arg['is_torrent_info_installed'] = False
        try:
            import torrent_info
            arg['is_torrent_info_installed'] = True
        except Exception as e:
            pass
        return render_template('%s_list.html' % package_name, arg=arg)
    elif sub == 'log':
        return render_template('log.html', package=package_name)
    return render_template('sample.html',
                           title='%s - %s' % (package_name, sub))
Beispiel #8
0
 def process_menu(self, sub, req):
     arg = P.ModelSetting.to_dict()
     arg['sub'] = self.name
     arg['sub2'] = sub
     try:
         if sub == 'movie':
             arg['library_list'] = PlexDBHandle.library_sections(
                 section_type=1)
         elif sub == 'show':
             arg['library_list'] = PlexDBHandle.library_sections(
                 section_type=2)
         elif sub == 'music':
             arg['library_list'] = PlexDBHandle.library_sections(
                 section_type=8)
         elif sub == 'cache':
             arg['scheduler'] = str(
                 scheduler.is_include(
                     self.sub_list[sub].get_scheduler_name()))
             arg['is_running'] = str(
                 scheduler.is_running(
                     self.sub_list[sub].get_scheduler_name()))
         return render_template(f'{package_name}_{name}_{sub}.html',
                                arg=arg)
     except Exception as e:
         logger.error(f'Exception:{str(e)}')
         logger.error(traceback.format_exc())
         return render_template('sample.html',
                                title=f"{package_name}/{name}/{sub}")
Beispiel #9
0
    def receive_scan_result(id, filename):
        try:
            import plex
            #with db.session.no_autoflush:
            logger.debug('Receive Scan Completed : %s-%s', id, filename)
            #modelfile = db.session.query(ModelKtvFile).filter_by(id=int(id)).with_for_update().first()
            modelfile = db.session.query(ModelKtvFile).filter_by(
                id=int(id)).first()
            if modelfile is not None:
                modelfile.scan_status = 3
                modelfile.scan_time = datetime.now()
                #if modelfile.plex_show_id == -1:
                plex.Logic.get_section_id(modelfile, more=True)
                #db.session.commit()
                if scheduler.is_running('ktv_process'):
                    Logic.plex_update_list.append(modelfile)
                    logger.debug('>> plex_update_list insert!!')
                else:
                    db.session.add(modelfile)
                    db.session.commit()
                    logger.debug('>> direct commit!!')

                if ModelSetting.query.filter_by(
                        key='telegram').first().value == 'True':
                    text = '<PLEX 스캔 완료 - KTV>\n%s\n\n%s' % (
                        modelfile.filename, modelfile.plex_part)
                    ToolBaseNotify.send_message(
                        text, message_id='fileprocess_ktv_scan_completed')

        except Exception as exception:
            logger.debug('>>>>> receive_scan_result')
            logger.error('Exception:%s', exception)
            logger.error(traceback.format_exc())
 def process_menu(self, sub, req):
     arg = P.ModelSetting.to_dict()
     arg['sub'] = self.name
     if sub == 'setting':
         job_id = '%s_%s' % (self.P.package_name, self.name)
         arg['scheduler'] = str(scheduler.is_include(job_id))
         arg['is_running'] = str(scheduler.is_running(job_id))
     return render_template(
         '{package_name}_{module_name}_{sub}.html'.format(
             package_name=P.package_name, module_name=self.name, sub=sub),
         arg=arg)
def detail(sub):
    if sub == 'setting':
        setting_list = db.session.query(ModelSetting).all()
        arg = Util.db_list_to_dict(setting_list)
        arg['scheduler'] = str(scheduler.is_include(package_name))
        arg['is_running'] = str(scheduler.is_running(package_name))
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub == 'log':
        return render_template('log.html', package=package_name)
    return render_template('sample.html',
                           title='%s - %s' % (package_name, sub))
Beispiel #12
0
 def process_menu(self, sub, req):
     arg = P.ModelSetting.to_dict()
     arg['sub'] = self.name
     if sub in ['setting', 'queue', 'list', 'request']:
         if sub == 'request' and req.args.get('content_code') is not None:
             arg['ani365_current_code'] = req.args.get('content_code')
         if sub == 'setting':
             job_id = '%s_%s' % (self.P.package_name, self.name)
             arg['scheduler'] = str(scheduler.is_include(job_id))
             arg['is_running'] = str(scheduler.is_running(job_id))
         return render_template('{package_name}_{module_name}_{sub}.html'.format(package_name=P.package_name, module_name=self.name, sub=sub), arg=arg)
     return render_template('sample.html', title='%s - %s' % (P.package_name, sub))
Beispiel #13
0
 def job_list():
     try:
         db_list = db.session.query(ModelCommand).filter().all()
         db_list = [x.as_dict() for x in db_list]
         from .logic_normal import LogicNormal
         for item in db_list:
             item['is_include'] = str(scheduler.is_include('command_%s' % item['id']))
             item['is_running'] = str(scheduler.is_running('command_%s' % item['id']))
             item['process_id'] = LogicNormal.process_list[item['id']].pid if item['id'] in LogicNormal.process_list and LogicNormal.process_list[item['id']] is not None else None
         return db_list
     except Exception as exception:
         logger.error('Exception:%s', exception)
         logger.error(traceback.format_exc())
Beispiel #14
0
 def process_menu(self, sub, req):
     try:
         arg = P.ModelSetting.to_dict()
         arg['sub'] = self.name
         if sub == 'setting':
             arg['scheduler'] = str(scheduler.is_include(self.get_scheduler_name()))
             arg['is_running'] = str(scheduler.is_running(self.get_scheduler_name()))
             arg['path_app_root'] = path_app_root
         return render_template(f'{package_name}_{name}_{sub}.html', arg=arg)
     except Exception as e:
         logger.error('Exception:%s', e)
         logger.error(traceback.format_exc())
         return render_template('sample.html', title=f"{package_name}/{name}/{sub}")
Beispiel #15
0
 def process_menu(self, sub, req):
     # 각 메뉴들이 호출될때 필요한 값들을 arg에 넘겨주어야함
     arg = P.ModelSetting.to_dict()
     arg['sub'] = self.name
     P.logger.debug('sub:%s', sub)
     if sub == 'setting':  # 설정페이지의 경우 스케쥴러 포함여부와 실행상태 전달
         job_id = '%s_%s' % (self.P.package_name, self.name)
         arg['scheduler'] = str(scheduler.is_include(job_id))
         arg['is_running'] = str(scheduler.is_running(job_id))
     return render_template(
         '{package_name}_{module_name}_{sub}.html'.format(
             package_name=P.package_name, module_name=self.name, sub=sub),
         arg=arg)
Beispiel #16
0
def first_menu(sub):
    logger.debug('DETAIL %s %s', package_name, sub)
    if sub == 'setting':
        arg = ModelSetting.to_dict()
        arg['package_name'] = package_name
        arg['scheduler'] = str(scheduler.is_include(package_name))
        arg['is_running'] = str(scheduler.is_running(package_name))
        return render_template('{package_name}_{sub}.html'.format(
            package_name=package_name, sub=sub),
                               arg=arg)
    elif sub == 'log':
        return render_template('log.html', package=package_name)
    return render_template('sample.html',
                           title='%s - %s' % (package_name, sub))
Beispiel #17
0
 def schedule_running():
     try:
         job_id_list = [
             'gallery-dl_normal', 'gallery-dl_data', 'gallery-dl_hitomi'
         ]
         for job_id in job_id_list:
             if scheduler.is_include(job_id):
                 if scheduler.is_running(job_id):
                     return True
         return False
     except Exception as e:
         logger.error('[gallery-dl] Exception:%s', e)
         logger.error(traceback.format_exc())
         ret = 'fail'
Beispiel #18
0
def detail(sub): 
    if sub == 'setting':
        setting_list = db.session.query(ModelSetting).all()
        arg = Util.db_list_to_dict(setting_list)
        arg['scheduler'] = str(scheduler.is_include(package_name))
        arg['is_running'] = str(scheduler.is_running(package_name))
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub in ['request', 'queue', 'list']:
        setting_list = db.session.query(ModelSetting).all()
        arg = Util.db_list_to_dict(setting_list)
        arg['current_code'] = LogicAni24.current_data['code'] if LogicAni24.current_data is not None else None
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub == 'log':
        return render_template('log.html', package=package_name)
    return render_template('sample.html', title='%s - %s' % (package_name, sub))
Beispiel #19
0
def detail(sub):
    if sub == 'setting':
        setting_list = db.session.query(ModelSetting).all()
        arg = Util.db_list_to_dict(setting_list)
        arg['scheduler'] = str(scheduler.is_include(package_name))
        arg['is_running'] = str(scheduler.is_running(package_name))
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub == 'status':
        arg = {}
        arg['is_running'] = str(scheduler.is_running(package_name))
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub == 'command_list':
        arg = {}
        arg['list_type'] = "command_list"
        return render_template('%s_list.html' % (package_name), arg=arg)
    elif sub == 'kthoom':
        return blueprint.send_static_file('index.html')
    elif sub == 'viewer':
        site = "/manamoa/kthoom?bookUri=dp"
        return render_template('iframe.html', site=site)
    elif sub == 'log':
        return render_template('log.html', package=package_name)
    return render_template('sample.html',
                           title='%s - %s' % (package_name, sub))
Beispiel #20
0
def second_menu(sub, sub2):
    try:
        arg = ModelSetting.to_dict()
        arg['package_name']  = package_name
        if sub == 'direct':
            if sub2 == 'setting':
                return render_template('%s_%s_%s.html' % (package_name, sub, sub2), arg=arg)
            elif sub2 in ['request']:
                return render_template('%s_%s_%s.html' % (package_name, sub, sub2), arg=arg)
        elif sub == 'rss':
            if sub2 == 'setting':
                arg['sub']  = sub
                arg['scheduler'] = str(scheduler.is_include('%s_%s' % (package_name, sub)))
                arg['is_running'] = str(scheduler.is_running('%s_%s' % (package_name, sub)))
                from system.model import ModelSetting as SystemModelSetting
                ddns = SystemModelSetting.get('ddns')
                arg['rss_api'] = '%s/%s/api/%s' % (ddns, package_name, sub)
                if SystemModelSetting.get_bool('auth_use_apikey'):
                    arg['rss_api'] += '?apikey=%s' % SystemModelSetting.get('auth_apikey')
                return render_template('%s_%s_%s.html' % (package_name, sub, sub2), arg=arg)
            elif sub2 in ['job', 'list']:
                arg['is_available_normal_download'] = False
                try:
                    import downloader
                    arg['is_available_normal_download'] = downloader.Logic.is_available_normal_download()
                except:
                    pass
                if sub2 == 'list':
                    arg['jobs'] = ModelOffcloud2Job.get_list(by_dict=True)
                return render_template('%s_%s_%s.html' % (package_name, sub, sub2), arg=arg)
        elif sub == 'cache':
            if sub2 == 'setting':
                arg['sub'] = sub
                from system.model import ModelSetting as SystemModelSetting
                ddns = SystemModelSetting.get('ddns')
                arg['rss_api'] = '%s/%s/api/%s' % (ddns, package_name, sub)
                if SystemModelSetting.get_bool('auth_use_apikey'):
                    arg['rss_api'] += '?apikey=%s' % SystemModelSetting.get('auth_apikey')
                return render_template('%s_%s_%s.html' % (package_name, sub, sub2), arg=arg)
            elif sub2 == 'list':
                arg['type'] = ['KTV', 'KTV_ETC', 'MOVIE', 'MOVIE_ETC', 'MUSIC', 'SHOW', 'ANI', 'PROGRAM', 'JAV_CENSORED_DMM', 'JAV_CENSORED_JAVDB', 'JAV_CENSORED_ETC', 'JAV_UNCENSORED', 'AV_WEST', 'AV_EAST', 'ETC']
                return render_template('%s_%s_%s.html' % (package_name, sub, sub2), arg=arg)
        return render_template('sample.html', title='%s - %s - %s' % (package_name, sub, sub2))
    except Exception as e: 
        logger.error('Exception:%s', e)
        logger.error(traceback.format_exc())
Beispiel #21
0
def first_menu(sub): 
    logger.debug('DETAIL %s %s', package_name, sub)
    if sub == 'setting':
        arg = ModelSetting.to_dict()
        arg['scheduler'] = str(scheduler.is_include(package_name))
        arg['is_running'] = str(scheduler.is_running(package_name))
        arg['tracker_list'] = ModelSetting.get('tracker_list').replace('\n', ', ')
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub in ['transmission', 'downloadstation', 'qbittorrent', 'aria2']:
        return redirect('/%s/%s/status' % (package_name, sub))
    elif sub in ['request', 'list', 'watch']:
        arg = ModelSetting.to_dict()
        arg['sub'] = sub
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub == 'log':
        return render_template('log.html', package=package_name)
    return render_template('sample.html', title='%s - %s' % (package_name, sub))
Beispiel #22
0
def first_menu(sub):
    arg = ModelSetting.to_dict()
    arg['package_name'] = package_name
    if sub == 'setting':

        arg['scheduler'] = str(scheduler.is_include(package_name))
        arg['is_running'] = str(scheduler.is_running(package_name))
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub == 'rss':
        try:
            import downloader
            arg['default_download_program'], arg[
                'default_download_path'] = downloader.Logic.get_default_value(
                )
            arg['default_download_path'] = arg[
                'default_download_path'].replace('\\', '\\\\')
        except:
            arg['default_download_program'] = '0'
            arg['default_download_path'] = ''
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub == 'list':
        arg['is_torrent_info_installed'] = False
        try:
            import torrent_info
            arg['is_torrent_info_installed'] = True
        except Exception as e:
            pass
        arg['is_offcloud_installed'] = False
        try:
            import offcloud2
            arg['is_offcloud_installed'] = True
        except Exception as e:
            pass
        try:
            arg['rss_id'] = request.args.get('rss_id')
        except Exception as e:
            pass
        if arg['rss_id'] is None:
            arg['rss_id'] = 'all'
        arg['rss_list'] = ModelRss.get_list(by_dict=True)
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub == 'log':
        return render_template('log.html', package=package_name)
    return render_template('sample.html',
                           title='%s - %s' % (package_name, sub))
Beispiel #23
0
def first_menu(sub): 
    #logger.debug('DETAIL %s %s', package_name, sub)
    try:
        arg = ModelSetting.to_dict()
        arg['package_name']  = package_name
        arg['ddns'] = SystemModelSetting.get('ddns')
        arg['auth_use_apikey'] = str(SystemModelSetting.get_bool('auth_use_apikey'))
        arg['auth_apikey'] = SystemModelSetting.get('auth_apikey')
        if sub == 'setting':
            arg['scheduler'] = str(scheduler.is_include(package_name))
            arg['is_running'] = str(scheduler.is_running(package_name))
            ddns = SystemModelSetting.get('ddns')
            arg['api_m3u'] = '{ddns}/{package_name}/api/m3u'.format(ddns=ddns, package_name=package_name)
            arg['api_m3utvh'] = '{ddns}/{package_name}/api/m3utvh'.format(ddns=ddns, package_name=package_name)
            arg['api_m3uall'] = '{ddns}/{package_name}/api/m3uall'.format(ddns=ddns, package_name=package_name)
            arg['xmltv'] = '{ddns}/epg/api/klive'.format(ddns=ddns)
            arg['plex_proxy'] = '{ddns}/{package_name}/proxy'.format(ddns=ddns, package_name=package_name)
            arg['wavve_vod'] = '{ddns}/{package_name}/wavve/api/m3u'.format(ddns=ddns, package_name=package_name)
            arg['tving_vod'] = '{ddns}/{package_name}/tving/api/m3u'.format(ddns=ddns, package_name=package_name)
            
            if SystemModelSetting.get_bool('auth_use_apikey'):
                apikey = SystemModelSetting.get('auth_apikey')
                for tmp in ['api_m3u', 'api_m3uall', 'api_m3utvh', 'xmltv', 'wavve_vod', 'tving_vod']:
                    arg[tmp] += '?apikey={apikey}'.format(apikey=apikey)

            from .source_streamlink import SourceStreamlink
            arg['tmp_is_streamlink_installed'] = 'Installed' if SourceStreamlink.is_installed() else 'Not Installed'
            from .source_youtubedl import SourceYoutubedl
            arg['tmp_is_youtubedl_installed'] = 'Installed' if SourceYoutubedl.is_installed() else 'Not Installed'
            return render_template('{package_name}_{sub}.html'.format(package_name=package_name, sub=sub), arg=arg)
        elif sub == 'list':
            
            return render_template('{package_name}_{sub}.html'.format(package_name=package_name, sub=sub), arg=arg)
        elif sub == 'custom_create':
            return render_template('{package_name}_{sub}.html'.format(package_name=package_name, sub=sub), arg=arg)
        elif sub == 'custom_edit':
            return render_template('{package_name}_{sub}.html'.format(package_name=package_name, sub=sub), arg=arg)
        elif sub == 'proxy':
            return redirect('/klive/proxy/discover.json')
        elif sub == 'log':
            return render_template('log.html', package=package_name)
        return render_template('sample.html', title='%s - %s' % (package_name, sub))
    except Exception as e: 
        logger.error('Exception:%s', e)
        logger.error(traceback.format_exc())
Beispiel #24
0
def first_menu(sub): 
    arg = ModelSetting.to_dict()
    arg['package_name']  = package_name
    if sub == 'setting':
        arg['scheduler'] = str(scheduler.is_include(package_name))
        arg['is_running'] = str(scheduler.is_running(package_name))
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub == 'request':
        if request.args.get('title_id') is not None:
            arg['recent_title_id'] = request.args.get('title_id')
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub == 'queue':
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub == 'list':
        return render_template('%s_%s.html' % (package_name, sub), arg=arg)
    elif sub == 'log':
        return render_template('log.html', package=package_name)
    return render_template('sample.html', title='%s - %s' % (package_name, sub))
Beispiel #25
0
def first_menu(sub):
    try:
        arg = ModelSetting.to_dict()
        arg['package_name'] = package_name
        if sub == 'setting':
            arg['scheduler'] = str(scheduler.is_include(package_name))
            arg['is_running'] = str(scheduler.is_running(package_name))
            return render_template('%s_%s.html' % (package_name, sub), arg=arg)

        elif sub == 'list':
            return render_template('%s_%s.html' % (package_name, sub), arg=arg)

        elif sub == 'log':
            return render_template('log.html', package=package_name)
    except Exception as e:
        logger.error('Exception:%s', e)
        logger.error(traceback.format_exc())
    return render_template('sample.html', title='%s - %s' % (package_name, sub))
Beispiel #26
0
 def process_menu(self, sub, req):
     arg = P.ModelSetting.to_dict()
     arg['sub'] = self.name
     arg['sub2'] = sub
     try:
         if sub == 'setting':
             arg['scheduler'] = str(
                 scheduler.is_include(
                     self.sub_list[sub].get_scheduler_name()))
             arg['is_running'] = str(
                 scheduler.is_running(
                     self.sub_list[sub].get_scheduler_name()))
         return render_template(f'{package_name}_{name}_{sub}.html',
                                arg=arg)
     except Exception as e:
         P.logger.error(f'Exception:{str(e)}')
         P.logger.error(traceback.format_exc())
         return render_template('sample.html',
                                title=f"{package_name}/{name}/{sub}")
Beispiel #27
0
def first_menu(sub):
    try:
        if sub == 'setting':
            arg = ModelSetting.to_dict()
            arg['package_name'] = package_name
            arg['scheduler'] = str(scheduler.is_include(package_name))
            arg['is_running'] = str(scheduler.is_running(package_name))
            arg['is_test_server'] = (SystemModelSetting.get('ddns').find(
                'https://sjva-dev.soju6jan.com') != -1)
            return render_template('%s_%s.html' % (package_name, sub), arg=arg)
        elif sub in ['site', 'scheduler', 'group']:
            arg = {'package_name': package_name}
            return render_template('%s_%s.html' % (package_name, sub), arg=arg)
        elif sub == 'search':
            arg = {}
            arg = {'package_name': package_name}
            arg['ddns'] = SystemModelSetting.get('ddns')

            try:
                import downloader
                arg['is_available_normal_download'] = downloader.Logic.is_available_normal_download(
                )
            except:
                arg['is_available_normal_download'] = False
            arg["search_word"] = request.args.get('search_word')
            arg['is_torrent_info_installed'] = False
            try:
                import torrent_info
                arg['is_torrent_info_installed'] = True
            except Exception as e:
                pass
            arg['apikey'] = ''
            if SystemModelSetting.get_bool('auth_use_apikey'):
                arg['apikey'] = SystemModelSetting.get('auth_apikey')

            return render_template('%s_%s.html' % (package_name, sub), arg=arg)
        elif sub == 'log':
            return render_template('log.html', package=package_name)
        return render_template('sample.html',
                               title='%s - %s' % (package_name, sub))
    except Exception as e:
        logger.error('Exception:%s', e)
        logger.error(traceback.format_exc())
 def invoke(self):
     try:
         logger.debug('invoke')
         telegram_invoke_action = ModelSetting.get('telegram_invoke_action')
         if telegram_invoke_action == '0':
             return False
         elif telegram_invoke_action == '1':
             if scheduler.is_include(package_name):
                 if scheduler.is_running(package_name):
                     return False
                 else:
                     scheduler.execute_job(package_name)
                     return True
         elif telegram_invoke_action == '2':
             P.logic.one_execute(self.name)
             return True
         else:
             return False
     except Exception, e:
         logger.error('Exception:%s', e)
         logger.error(traceback.format_exc())
Beispiel #29
0
 def one_execute(sub):
     logger.debug('one_execute :%s', sub)
     try:
         job_id = '%s_%s' % (package_name, sub)
         if scheduler.is_include(job_id):
             if scheduler.is_running(job_id):
                 ret = 'is_running'
             else:
                 scheduler.execute_job(job_id)
                 ret = 'scheduler'
         else:
             def func():
                 time.sleep(2)
                 Logic.scheduler_function(sub)
             threading.Thread(target=func, args=()).start()
             ret = 'thread'
     except Exception as e: 
         logger.error('Exception:%s', e)
         logger.error(traceback.format_exc())
         ret = 'fail'
     return ret
Beispiel #30
0
def first_menu(sub):
    ## setting 메뉴가 호출되면
    if sub == 'setting':
        ## 화면에 보여줄 모든 정보를 arg 에 넣습니다.
        arg = ModelSetting.to_dict()
        arg['package_name'] = package_name
        arg['scheduler'] = str(scheduler.is_include(package_name))
        arg['is_running'] = str(scheduler.is_running(package_name))
        return render_template('{package_name}_{sub}.html'.format(
            package_name=package_name, sub=sub),
                               arg=arg)
    ## 아래 로그와 샘플을 그대로 사용
    elif sub == 'list':
        arg = {}
        arg['package_name'] = package_name
        return render_template('{package_name}_{sub}.html'.format(
            package_name=package_name, sub=sub),
                               arg=arg)
    elif sub == 'log':
        return render_template('log.html', package=package_name)
    return render_template('sample.html',
                           title='%s - %s' % (package_name, sub))