Esempio n. 1
0
 def func():
     RcloneTool.do_action(
         ModelSetting.get('rclone_path'),
         ModelSetting.get('rclone_config_path'),
         mode,
         server_type,
         folder_id,
         folder_name,
         server_filename,
         remote_path,
         action,
         folder_id_encrypted=True)
     if mode == 'upload' and server_type == 'content':
         tmp = remote_path.split('/')
         tmp2 = tmp[-1].split('.')
         if tmp2[-1].lower() in [
                 'mp4', 'mkv', 'avi', 'wmv', 'srt'
         ]:
             url = SERVER_URL + '/gd_share_server/noapi/av_sub/refresh?folder_name=%s' % folder_name
         else:
             #url = SERVER_URL + '/gd_share_server/noapi/av_sub/refresh?folder_name=%s' % tmp[-1]
             pass
         data = requests.get(url).json()
     msg = u'모두 완료되었습니다.\n'
     socketio.emit("command_modal_add_text",
                   str(msg),
                   namespace='/framework',
                   broadcast=True)
Esempio n. 2
0
 def process_ajax(sub, req):
     try:
         if sub == 'rclone_lsjson':
             remote_path = req.form['remote_path']
             ret = RcloneTool.lsjson(ModelSetting.get('rclone_path'), ModelSetting.get('rclone_config_path'), remote_path)
             return jsonify(ret)
         elif sub == 'rclone_size':
             remote_path = req.form['remote_path']
             ret = RcloneTool.size(ModelSetting.get('rclone_path'), ModelSetting.get('rclone_config_path'), remote_path)
             return jsonify(ret)
         elif sub == 'conf_get':
             rclone_config_path = req.form['rclone_config_path']
             from framework.common.util import read_file
             ret = {'ret':False, 'data':''}
             if os.path.exists(rclone_config_path):
                 ret['ret'] = True
                 ret['data'] = read_file(rclone_config_path)
             return jsonify(ret)
         elif sub == 'conf_save':
             rclone_config_path = req.form['rclone_config_path']
             data = req.form['conf_text']
             data = data.replace("\r\n", "\n" ).replace( "\r", "\n" )
             with open(rclone_config_path, 'w') as f: 
                 f.write(data)
             return jsonify(True)
     except Exception as e: 
         logger.error('Exception:%s', e)
         logger.error(traceback.format_exc())
Esempio n. 3
0
    def copy(folder_id, folder_name, size, board_type, category_type):
        try:
            my_remote_path = LogicUser.get_my_copy_path(board_type, category_type)
            if my_remote_path is None:
                return
            if my_remote_path.startswith('gc:'):
                try:
                    from rclone_expand.logic_gclone import LogicGclone
                    tmp = ['gc:{%s}|%s/%s' % (RcloneTool.folderid_decrypt(folder_id), my_remote_path, folder_name)]
                    LogicGclone.queue_append(tmp)
                except Exception as e: 
                    logger.error('Exception:%s', e)
                    logger.error(traceback.format_exc())
            else:
                def func():
                    ret = RcloneTool.do_action(ModelSetting.get('rclone_path'), ModelSetting.get('rclone_config_path'),  'download', '', folder_id, folder_name, '', my_remote_path, 'real', folder_id_encrypted=True, listener=None)

                    if ret['percent'] == 100:
                        tmp = ModelSetting.get_int('size_download')
                        tmp += size
                        ModelSetting.set('size_download', str(tmp))

                    msg = u'모두 완료되었습니다.'
                    socketio.emit("command_modal_add_text", str(msg), namespace='/framework', broadcast=True)

                thread = threading.Thread(target=func, args=())
                thread.setDaemon(True)
                thread.start()
            return my_remote_path
            
            
        except Exception as e: 
            logger.error('Exception:%s', e)
            logger.error(traceback.format_exc())
Esempio n. 4
0
            def func():
                ret = RcloneTool.do_action(ModelSetting.get('rclone_path'), ModelSetting.get('rclone_config_path'), action, 'category', folder_id, folder_name, '', my_remote_path, 'real', folder_id_encrypted=True, listener=None)

                msg = u'Percent : %s\n' % ret['percent']
                socketio.emit("command_modal_add_text", str(msg), namespace='/framework', broadcast=True)
                #msg = u'폴더ID : %s\n' % ret['folder_id']
                #socketio.emit("command_modal_add_text", str(msg), namespace='/framework', broadcast=True)

                if ret['percent'] == 100:
                    msg = u'업로드 크기 적용..\n'
                    socketio.emit("command_modal_add_text", str(msg), namespace='/framework', broadcast=True)
                    tmp = ModelSetting.get_int('size_upload')
                    tmp += size
                    ModelSetting.set('size_upload', str(tmp))
                    logger.debug('폴더ID:%s', ret['folder_id'])
                    if board_type != 'share_private' and ret['folder_id'] != '':
                        msg = u'게시물 등록중...\n'
                        socketio.emit("command_modal_add_text", str(msg), namespace='/framework', broadcast=True)
                        
                        data = {'board_type' : board_type, 'category_type':category_type, 'board_title':board_title, 'board_content':board_content, 'board_daum_url' : board_daum_url, 'folder_name':folder_name, 'size':size, 'daum_info':daum_info, 'folder_id':ret['folder_id'], 'user_id':user_id, 'lsjson' : json.dumps(ret['lsjson'])}
                        LogicUser.site_append(data)
                    else:
                        msg = u'업로드한 폴더ID값을 가져올 수 없어서 사이트 등록에 실패하였습니다.\n관리자에게 등록 요청하세요.\n'
                        socketio.emit("command_modal_add_text", str(msg), namespace='/framework', broadcast=True)
                msg = u'모두 완료되었습니다.\n'
                socketio.emit("command_modal_add_text", str(msg), namespace='/framework', broadcast=True)
Esempio n. 5
0
 def func():
     for i in range(1, 11):
         logger.debug('VOD 다운로드 시도 : %s %s', i, fileid)
         ret = RcloneTool.fileid_copy(ModelSetting.get('rclone_path'), ModelSetting.get('rclone_config_path'), fileid, remote_path)
         if ret:
             break
         time.sleep(30)
Esempio n. 6
0
 def process_ajax(sub, req):
     try:
         if sub == 'rclone_lsjson':
             remote_path = req.form['remote_path']
             ret = RcloneTool.lsjson(ModelSetting.get('rclone_path'),
                                     ModelSetting.get('rclone_config_path'),
                                     remote_path)
             return jsonify(ret)
         elif sub == 'rclone_size':
             remote_path = req.form['remote_path']
             ret = RcloneTool.size(ModelSetting.get('rclone_path'),
                                   ModelSetting.get('rclone_config_path'),
                                   remote_path)
             return jsonify(ret)
     except Exception as e:
         logger.error('Exception:%s', e)
         logger.error(traceback.format_exc())
Esempio n. 7
0
            def func():
                ret = RcloneTool.do_action(ModelSetting.get('rclone_path'), ModelSetting.get('rclone_config_path'),  'download', '', folder_id, folder_name, '', my_remote_path, 'real', folder_id_encrypted=True, listener=None)

                if ret['percent'] == 100:
                    tmp = ModelSetting.get_int('size_download')
                    tmp += size
                    ModelSetting.set('size_download', str(tmp))

                msg = u'모두 완료되었습니다.'
                socketio.emit("command_modal_add_text", str(msg), namespace='/framework', broadcast=True)
Esempio n. 8
0
 def func():
     for i in range(1, 21):
         logger.debug('토렌트 다운로드 시도 : %s %s', i, folder_id)
         ret = RcloneTool.do_action(ModelSetting.get('rclone_path'), ModelSetting.get('rclone_config_path'),  'download', '', folder_id, '', '', my_remote_path, 'real', folder_id_encrypted=True, listener=None)
         logger.debug(ret)
         if ret['percent'] == 0:
             msg = u'아직 토렌트 파일을 받지 못했습니다. 30초 후 다시 시도합니다. (%s/20)' % i
             socketio.emit("command_modal_add_text", str(msg), namespace='/framework', broadcast=True)
             time.sleep(30)
         else:
             msg = u'모두 완료되었습니다.'
             socketio.emit("command_modal_add_text", str(msg), namespace='/framework', broadcast=True)
             break
         logger.debug(msg)
Esempio n. 9
0
 def torrent_copy(folder_id, board_type, category_type, my_remote_path=None):
     try:
         if my_remote_path is None:
             my_remote_path = LogicUser.get_my_copy_path(board_type, category_type)
         if my_remote_path is None:
             return
         # 시간차이가 있어서 바로 다운로드가 안되는 문제 발생
         # 폴더id의 내용이 있는지 확인
         
         if my_remote_path.startswith('gc:'):
             try:
                 from rclone_expand.logic_gclone import LogicGclone
                 tmp = ['gc:{%s}|%s' % (RcloneTool.folderid_decrypt(folder_id), my_remote_path)]
                 LogicGclone.queue_append(tmp)
             except Exception as e: 
                 logger.error('Exception:%s', e)
                 logger.error(traceback.format_exc())
         else:
             def func():
                 for i in range(1, 21):
                     logger.debug('토렌트 다운로드 시도 : %s %s', i, folder_id)
                     ret = RcloneTool.do_action(ModelSetting.get('rclone_path'), ModelSetting.get('rclone_config_path'),  'download', '', folder_id, '', '', my_remote_path, 'real', folder_id_encrypted=True, listener=None)
                     logger.debug(ret)
                     if ret['percent'] == 0:
                         msg = u'아직 토렌트 파일을 받지 못했습니다. 30초 후 다시 시도합니다. (%s/20)' % i
                         socketio.emit("command_modal_add_text", str(msg), namespace='/framework', broadcast=True)
                         time.sleep(30)
                     else:
                         msg = u'모두 완료되었습니다.'
                         socketio.emit("command_modal_add_text", str(msg), namespace='/framework', broadcast=True)
                         break
                     logger.debug(msg)
             thread = threading.Thread(target=func, args=())
             thread.setDaemon(True)
             thread.start()
         return my_remote_path
     except Exception as e: 
         logger.error('Exception:%s', e)
         logger.error(traceback.format_exc())
Esempio n. 10
0
            def func():
                ret = RcloneTool.do_action(ModelSetting.get('rclone_path'), ModelSetting.get('rclone_config_path'),  'download', '', folder_id, '', '', my_remote_path, 'real', folder_id_encrypted=True, listener=None)

                msg = u'모두 완료되었습니다.'
                socketio.emit("command_modal_add_text", str(msg), namespace='/framework', broadcast=True)