Example #1
0
 def __init__(self, ui_code, folder_id):
     self.created_time = datetime.now()
     self.ui_code = py_unicode(ui_code)
     self.folder_id = py_unicode(folder_id)
     self.shortcut_created = False
     self.shortcut_count = 0
     self.excluded = False
Example #2
0
    def __init__(self, name, rule_id, folder_id, parent_folder_id):
        self.created_time = datetime.now()

        self.name = py_unicode(name)
        self.rule_id = rule_id
        self.folder_id = py_unicode(folder_id)
        self.parent_folder_id = py_unicode(parent_folder_id)
Example #3
0
 def __init__(self, name, folder_id, rule_name, rule_id):
     self.created_time = datetime.now()
     self.name = py_unicode(name)
     self.folder_id = py_unicode(folder_id)
     self.rule_name = py_unicode(rule_name)
     self.rule_id = rule_id
     self.shortcut_created = False
     self.updated_time = datetime.now()
     self.excluded = False
Example #4
0
    def save_as_dict(d):
        try:
            entity = WSModelItem()
            entity.doc_id = py_unicode(d['doc_id'])
            entity.doc_title = py_unicode(d['doc_title'])
            entity.ws_id = py_unicode(d['ws_id'])
            entity.ws_title = py_unicode(d['ws_title'])
            entity.doc_url = py_unicode(d['doc_url'])
            entity.in_schedule = d['in_schedule']

            db.session.add(entity)
            db.session.commit()
        except Exception as e:
            logger.error(d)
            logger.error('Exception:%s', e)
Example #5
0
    def move_ktv_show_genre(data, info, base_path):
        etc_name = ModelSetting.get('etc_show_genre')
        try:
            set_genre = []
            logger.debug('=== title %s', data['dest_folder_name'])
            if 'genre' in info:
                set_genre = info['genre']
            else:
                if LogicNormal.isHangul(etc_name) > 0:
                    str = py_unicode(etc_name)
                    etc_name = str
                set_genre = etc_name
            title = data['dest_folder_name']
            fullPath = data['fullPath']

            set_genre = LogicNormal.to_str(set_genre)
            title = LogicNormal.to_str(title)
            dest_folder_path = os.path.join(base_path.strip(), set_genre, title)
            if not os.path.exists(dest_folder_path):
                os.makedirs(dest_folder_path)
            fileCheck = os.path.join(dest_folder_path, data['name'])
            if not os.path.isfile(fileCheck):
                fullPath = LogicNormal.to_str(fullPath)
                shutil.move(fullPath, dest_folder_path)
                LogicNormal.db_save(data, dest_folder_path, u'일치', True)
        except Exception as e:
            logger.error('Exxception:%s', e)
            logger.error(traceback.format_exc())
Example #6
0
    def movie_path_country(info, option):
        etc_name = ModelSetting.get('etc_movie_country')
        try:
            country = ""
            set_country = ""
            if 'more' in info:
                if 'country' in info['more']:
                    country = info['more']['country']
            else:
                if 'country' in info:
                    country = info['country']

            if country is not None:
                country = country.encode('utf-8')
                for keywords, values in option.items():
                    encKeywords = keywords.encode('utf-8')
                    gregx = re.compile(encKeywords, re.I)
                    #logger.debug('mpc - country:%s, values:%s', country, values)
                    if (gregx.search(country)) is not None:
                        encValues = values.encode('utf-8')
                        set_country = encValues
                        logger.debug('mpc search - country:%s, encValues:%s', country, encValues)
                        break
                    else:
                        if LogicNormal.isHangul(etc_name) > 0:
                            str = py_unicode(etc_name)
                            etc_name = str
                        set_country = etc_name
                return set_country
            else:
                return None
        except Exception as e:
            logger.error('Exxception:%s', e)
            logger.error(traceback.format_exc())
Example #7
0
    def movie_path_rate(info, option):
        etc_name = ModelSetting.get('etc_movie_rate')
        try:
            rate = []
            set_rate = ""
            if 'more' in info:
                if 'rate' in info['more']:
                    rate = info['more']['rate']

            if rate is not None:
                rate = rate.encode('utf-8')
                for keywords, values in option.items():
                    encKeywords = keywords.encode('utf-8')
                    gregx = re.compile(encKeywords, re.I)
                    #logger.debug('mpr - rate:%s, values:%s', rate, values)
                    if (gregx.search(rate)) is not None:
                        encValues = values.encode('utf-8')
                        set_rate = encValues
                        logger.debug('mpr search - rate:%s, encValues:%s', rate, encValues)
                        break
                    else:
                        if LogicNormal.isHangul(etc_name) > 0:
                            str = py_unicode(etc_name)
                            etc_name = str
                        set_rate = etc_name
                return set_rate
            else:
                return None
        except Exception as e:
            logger.error('Exxception:%s', e)
            logger.error(traceback.format_exc())
Example #8
0
    def save_as_dict(item):
        try:
            entity = ModelItem()
            entity.name = py_unicode(item['name'])
            entity.fileName = py_unicode(item['fileName'])
            entity.dirName = py_unicode(item['dirName'])
            entity.targetPath = py_unicode(item['targetPath'])
            entity.match_type = py_unicode(item['match_type'])
            entity.is_moved = item['is_moved']

            db.session.add(entity)
            db.session.commit()
        except Exception as e:
            logger.debug(item)
            logger.error('Exception:%s', e)
            logger.error(traceback.format_exc())
Example #9
0
    def apply_meta(req):
        try:
            db_id = int(req.form['id'])
            entity = ModelTvMvItem.get_by_id(db_id)

            code = req.form['code']
            title = req.form['title']
            site = req.form['site']

            info = ScmUtil.info_metadata(entity.agent_type, code, title)
            if info == None:
                logger.error(u'메타정보 조회실패: %s:%s', rule.agent_type, title)
                return { 'ret':'error', 'msg':'"{}"의 메타정보 조회실패.'.format(title) }

            entity.code = py_unicode(info['code'])
            entity.status = info['status']
            entity.site = py_unicode(info['site'])
            entity.poster_url = py_unicode(info['poster_url'])
            entity.studio = py_unicode(info['studio'])
            entity.year = py_unicode(info['year'])
            entity.genre = py_unicode(info['genre'])
            entity.title = py_unicode(title)
            entity.save()
            
            return { 'ret':'success', 'msg':'"{}"의 메타정보 적용완료.'.format(entity.title) }

        except Exception as e:
            logger.debug('Exception:%s', e)
            logger.debug(traceback.format_exc())
            return { 'ret':'error', 'msg':'에러발생! 로그를 확인해주세요.' }
Example #10
0
    def save_as_dict(d):
        try:
            logger.debug(d)
            entity = db.session.query(ModelItem).filter_by(
                id=d['id']).with_for_update().first()
            if entity is not None:
                entity.status = d['status']
                entity.str_status = py_unicode(d['str_status'])
                entity.title_id = d['title_id']
                entity.episode_id = d['episode_id']
                entity.title = py_unicode(d['title'])
                entity.episode_title = py_unicode(d['episode_title'])
                entity.download_count = d['download_count']
                entity.filename = d['filename']

                db.session.commit()
        except Exception as e:
            logger.error('Exception:%s', e)
            logger.error(traceback.format_exc())
Example #11
0
 def check_resolution(info):
     rules_uhd = ['4K', '4k', 'UHD', '2160p', '2160P']
     rules_fhd = ['1080p', '1080P', 'fhd', 'FHD']
     rules_hd = ['720p', '720P', 'hd', 'HD']
     fileName = ""
     try:
         #remove hdr word
         #fileName = info['name']
         #fileName = re.sub(r'HDR', '', fileName, flags=re.IGNORECASE)
         if LogicNormal.isHangul(info['name']) > 0:
             str = py_unicode(info['name'])
             fileName = str
         else:
             fileName = info['name']
         fileName = re.sub('[-=+,#/\?:^$.@*\"※~&%ㆍ!』\\‘|\(\)\[\]\<\>`\'…》]', ' ', fileName)
         logger.debug('cr - fileName: %s', fileName)
         for keywords in rules_uhd:
             gregx = re.compile(keywords, re.I)
             if (gregx.search(fileName)):
                 info['uhd'] += 1
         for keywords in rules_fhd:
             gregx = re.compile(keywords, re.I)
             if (gregx.search(fileName)):
                 info['fhd'] += 1
         for keywords in rules_hd:
             gregx = re.compile(keywords, re.I)
             if (gregx.search(fileName)):
                 info['hd'] += 1
         logger.debug('cr - uhd:%s, fhd:%s, hd:%s', info['uhd'], info['fhd'], info['hd'])
         if info['uhd'] >= 1 and info['fhd'] >= 1:
             if int(info['uhd']) > int(info['fhd']):
                 info['uhd'] = 1
                 info['fhd'] = 0
             else:
                 info['uhd'] = 0
                 info['fhd'] = 1
         elif info['uhd'] >= 1 and info['hd'] >= 1:
             info['uhd'] = 1
             info['hd'] = 0
         elif info['fhd'] >= 1 and info['hd'] >= 1:
             info['fhd'] = 1
             info['hd'] = 0
         logger.debug('cr - uhd:%s, fhd:%s, hd:%s', info['uhd'], info['fhd'], info['hd'])
         return info
     except Exception as e:
         logger.error('Exxception:%s', e)
         logger.error(traceback.format_exc())
Example #12
0
 def __init__(self, info):
     self.created_time = datetime.now()
     self.name = py_unicode(info['name'])
     self.agent_type = py_unicode(info['agent_type'])
     self.root_folder_id = py_unicode(info['root_folder_id'])
     self.root_full_path = py_unicode(info['root_full_path'])
     self.max_depth = info['max_depth']
     self.target_folder_id = py_unicode(info['target_folder_id'])
     self.target_full_path = py_unicode(info['target_full_path'])
     self.item_count = 0
     self.shortcut_count = 0
     self.use_sub_folder = info['use_subfolder']
     self.subfolder_rule = py_unicode(info['subfolder_rule'])
     self.use_auto_create_shortcut = info['use_auto_create_shortcut']
     self.use_schedule = info['use_schedule']
     self.use_plex = info['use_plex']
     self.last_search_time = None
Example #13
0
    def save_as_dict(d):
        try:
            entity = ListModelItem()
            entry.sheet_id = py_unicode(d['sheet_id'])
            entry.title = py_unicode(d['title'])
            entry.title2 = py_unicode(d['title2'])
            entry.folder_id = py_unicode(d['folder_id'])
            entry.category = py_unicode(d['category'])
            entry.copy_count = d['copy_count']
            entry.obj_num = d['obj_num']
            entry.category = py_unicode(d['category'])
            entry.str_size = py_unicode(d['str_size'])
            entry.byte_size = d['str_size']
            entry.mimetype = d['mime_type']

            db.session.add(entity)
            db.session.commit()
        except Exception as e:
            logger.error(d)
            logger.error('Exception:%s', e)
Example #14
0
 def item_list(path, f):
     try:
         item = {}
         item['path'] = path
         item['name'] = f
         if 'Trailer' in f:
             return None
         item['fullPath'] = os.path.join(path, f)
         temp = re.sub('(s|S)+\d\d', '', f)
         #logger.debug('il1 - %s : %s', item['name'], temp)
         temp = re.sub('-\d?\d', '', temp)
         #logger.debug('il2 - %s : %s', item['name'], temp)
         temp = re.sub('\d?\d회 ?합?본?', '', temp)
         #temp = re.sub('\d\d-\d\d회 합본', '', temp)
         #logger.debug('il3 - %s : %s', item['name'], temp)
         logger.debug('il4 - temp:%s', temp)
         #item['guessit'] = guessit(temp, options={'date-day-first': True})
         item['guessit'] = guessit(temp)
         item['ext'] = os.path.splitext(f)[1].lower()
         item['search_name'] = None
         item['uhd'] = 0
         item['hd'] = 0
         item['fhd'] = 0
         #match = re.compile('^(?P<name>.*?)[\\s\\.\\[\\_\\(]\\d{4}').match(item['name'])
         match = re.compile('^(?P<name>.*?)[\\s\\.\\[\\_\\(]\\d{4}').match(temp)
         if match:
             item['search_name'] = match.group('name').replace('.', ' ').strip()
             item['search_name'] = re.sub('\\[(.*?)\\]', '', item['search_name'])
         else:
             return None
         if LogicNormal.isHangul(item['search_name']) > 0:
             str = py_unicode(item['search_name'])
             item['search_name'] = str
         logger.debug('il5 - search_name:%s', item['search_name'])
         return item
     except Exception as e:
         logger.error('Exxception:%s', e)
         logger.error(traceback.format_exc())
Example #15
0
 def movie_path_genre(info, option):
     ani_flag = ModelSetting.get_bool('ani_flag')
     etc_name = ModelSetting.get('etc_movie_genre')
     genre_list = []
     try:
         set_genre = None
         if 'more' in info:
             if 'genre' in info['more']:
                 for word in info['more']['genre']:
                     if ani_flag == 1:
                         if u'애니메이션' in word :
                             return None
         #num_genre = len(info['more']['genre'])
         logger.debug('mpg check %s', info['more']['genre'])
         genre_list = info['more']['genre']
         if isinstance(genre_list, list):
             genre = genre_list[0]
         else:
             genre = genre_list
         for keywords, values in option.items():
             genre = genre.encode('utf-8')
             encKeywords = keywords.encode('utf-8')
             gregx = re.compile(encKeywords, re.I)
             if (gregx.search(genre)) is not None:
                 encValues = values.encode('utf-8')
                 set_genre = encValues
                 logger.debug('mpg search - genre:%s, encValues:%s', genre, encValues)
                 break
             else:
                 if LogicNormal.isHangul(etc_name) > 0:
                     str = py_unicode(etc_name)
                     etc_name = str
                 set_genre = etc_name
         logger.debug('mpg ret genre:%s', set_genre)
         return set_genre
     except Exception as e:
         logger.error('Exxception:%s', e)
         logger.error(traceback.format_exc())
Example #16
0
    def convert_one_file_logic(smi_file, srt_file):
        try:
            ret = {'smi_file': smi_file}
            if not os.path.exists(smi_file):
                return {'ret': 'fail'}

            encoding = SMI2SRTHandle.predict_encoding(smi_file).lower()

            if encoding is not None:
                if encoding.startswith('utf-16') or encoding.startswith(
                        'utf-8'):
                    encoding2 = encoding
                else:
                    encoding2 = 'cp949'
                log_debug('File encoding : %s %s', encoding, encoding2)
                #if encoding == 'EUC-KR' or encoding == 'ascii' or encoding == 'Windows-1252' or encoding == 'ISO-8859-1':
                #   encoding = 'cp949'
                ret['encoding1'] = encoding
                ret['encoding2'] = encoding2
                try:
                    ifp = codecs.open(smi_file, 'r', encoding=encoding2)
                    smi_sgml = ifp.read()
                    smi_sgml = smi_sgml.encode('utf-8')
                    ret['is_success_file_read'] = True
                except Exception as e:
                    ret['is_success_file_read'] = False
                    log_debug('Exception:%s', e)
                    #log_debug(traceback.format_exc())
                    log_debug('line read logic start..')
                    ifp = io.open(smi_file, 'rb')
                    lines = []
                    count = 0
                    while True:
                        line = ifp.readline()
                        if not line:
                            break
                        try:
                            lines.append(
                                unicode(line,
                                        encoding.lower()).encode('utf-8'))
                        except:
                            count += 1
                            pass
                    smi_sgml = '\n'.join(lines)
                    log_debug('line except count :%s', count)
                    ret['except_line_count'] = count
            else:
                return {'ret': 'fail'}

            data = SMI2SRTHandle.demuxSMI(smi_sgml)
            ret['lang_count'] = len(data)
            ret['srt_list'] = []
            #for lang, smi_sgml in data.iteritems():
            for lang, smi_sgml in data.items():
                log_debug('lang info : %s', lang)
                try:
                    try:
                        fndx = smi_sgml.upper().find('<SYNC')
                    except Exception as e:
                        raise e

                    if fndx < 0:
                        ret['ret'] = SMI2SRTHandle.process_not_sync_tag(
                            smi_sgml)
                        return ret
                    smi_sgml = smi_sgml[fndx:]
                    lines = smi_sgml.split('\n')

                    srt_list = []
                    sync_cont = ''
                    si = None
                    last_si = None
                    linecnt = 0
                    #logger.debug(len(lines))
                    for index, line in enumerate(lines):
                        linecnt += 1
                        sndx = line.upper().find('<SYNC')
                        if sndx >= 0:
                            m = re.search(r'<sync\s+start\s*=\s*(\d+)>(.*)$',
                                          line,
                                          flags=re.IGNORECASE)
                            if not m:
                                m = re.search(
                                    r'<sync\s+start\s*=\s*(\d+)\send\s*=(\d+)>(.*)$',
                                    line,
                                    flags=re.IGNORECASE)
                            if not m:
                                m = re.search(
                                    r'<sync\s+start\s*=-\s*(\d+)>(.*)$',
                                    line,
                                    flags=re.IGNORECASE)
                            if not m:
                                # <SYNC Start="100">, 마지막 > 태그 없는거
                                m = re.search(
                                    r'<SYNC\s+Start\s*=\"?(\d+)\"?>?(.*)$',
                                    line,
                                    flags=re.IGNORECASE)
                            if not m:
                                #<SYNC S tart=1562678
                                m = re.search(
                                    r'<sync\s+s\s*t\s*a\s*r\s*t\s*=\s*(\d+)>(.*)$',
                                    line,
                                    flags=re.IGNORECASE)
                            if not m:
                                line2 = line.lower().replace(
                                    '<sync start=>', '<sync start=0>')
                                #2019-09-15
                                line2 = line2.lower().replace(
                                    '<sync start=nan>', '<sync start=0>')
                                line2 = line2.lower().replace(
                                    "<sync st,rt=", '<sync start=')
                                line2 = line2.lower().replace(
                                    "<sync s,art=", '<sync start=')
                                m = re.search(
                                    r'<sync\s+start\s*=\s*(\d+)>(.*)$',
                                    line2,
                                    flags=re.IGNORECASE)
                            if not m:
                                #2020-06-15 음수.
                                m = re.search(r'<sync\s+start\s*=-(\d+)',
                                              line,
                                              flags=re.IGNORECASE)
                                if m:
                                    ret['log'] = u'-시간 태그 있음.'
                                    continue
                            if not m:
                                if index == len(lines) - 1:
                                    #맨 마지막 문장이라면 pass
                                    ret['log'] = u'마지막 문장 %s 으로 끝남.' % line.strip(
                                    )
                                    continue
                                elif line.strip().upper() == '<SYNC':
                                    # 종종 보임. 어짜피 다음 태그가 정상이니 패스
                                    continue
                                else:
                                    ret['log'] = u'태그 분석 실패. %s:%s' % (index,
                                                                       line)
                                    raise Exception(
                                        'AAAAAA format tag of <Sync start=nnnn> with "%s:%s"'
                                        % (index, line.strip()))
                            sync_cont += line[0:sndx]
                            last_si = si
                            if last_si != None:
                                last_si.end_ms = int(m.group(1))
                                last_si.contents = sync_cont
                                srt_list.append(last_si)
                                last_si.linecount = linecnt
                            sync_cont = m.group(2)
                            si = smiItem()
                            si.start_ms = int(m.group(1))
                        else:
                            sync_cont += line

                    #ofp = io.open(srt_file, 'w', encoding="utf8")
                    #ofp = open(srt_file, 'w')
                    if lang == 'KRCC':
                        tmp_srt_file = srt_file
                    else:
                        if srt_file.endswith('.ko.srt'):
                            tmp_srt_file = srt_file.replace(
                                '.ko.srt', '.%s.srt' % lang.lower()[:2])
                        else:
                            tmp_srt_file = srt_file.replace(
                                '.srt', '.%s.srt' % lang.lower()[:2])

                    ofp = codecs.open(tmp_srt_file, 'w', encoding='utf8')
                    ndx = 1
                    for si in srt_list:
                        si.convertSrt()
                        if si.contents == None or len(si.contents) <= 0:
                            continue
                        sistr = '%d\n%s --> %s\n%s\n\n' % (
                            ndx, si.start_ts, si.end_ts, si.contents)
                        #sistr = py_unicode(sistr, 'utf-8').encode('euc-kr')
                        sistr = py_unicode(sistr)
                        ofp.write(sistr)
                        ndx += 1
                    ofp.close()
                    ret['srt_list'].append({
                        'lang': lang,
                        'srt_file': tmp_srt_file
                    })
                except Exception as e:
                    log_debug('Exception:%s', e)
                    log_debug(traceback.format_exc())
                    ret['ret'] = 'fail'
                    return ret
            ret['ret'] = 'success'
            return ret
        except Exception as e:
            log_debug('Exception:%s', e)
            log_debug(traceback.format_exc())
            ret['ret'] = 'fail'
            return ret
Example #17
0
    def convert_directory(work_path, lists=None):
        log_debug("convert_directory : <%s>" % work_path)
        try:
            if lists is None:
                lists = os.listdir(py_unicode(work_path))
            for item in lists:
                try:
                    eachfile = os.path.join(work_path, item)
                    if os.path.isdir(eachfile):
                        SMI2SRTHandle.convert_directory(eachfile)
                    elif os.path.isfile(eachfile):
                        if eachfile[-4:].lower() == '.smi':
                            rndx = eachfile.rfind('.')
                            if SMI2SRTHandle.no_append_ko or eachfile.lower(
                            ).endswith('.kor.smi') or eachfile.lower(
                            ).endswith('.ko.smi'):
                                srt_file = '%s.srt' % eachfile[0:rndx]
                            else:
                                srt_file = '%s.ko.srt' % eachfile[0:rndx]
                            if os.path.exists(srt_file):
                                if SMI2SRTHandle.remake:
                                    #log_debug('remake is true..')
                                    pass
                                else:
                                    #log_debug('remake is false..')
                                    continue
                            log_debug(
                                '=========================================')
                            log_debug("Convert start : <%s>" % eachfile)
                            log_debug('srt filename : %s', srt_file)
                            ret = SMI2SRTHandle.convert_one_file_logic(
                                eachfile, srt_file)
                            log_info("Convert result : %s", ret)
                            if ret['ret'] == "success":
                                if not SMI2SRTHandle.no_remove_smi:
                                    log_debug("remove smi")
                                    os.remove(eachfile)
                            elif ret['ret'] == "not_smi":
                                if SMI2SRTHandle.not_smi_move_path != "":
                                    target = os.path.join(
                                        SMI2SRTHandle.not_smi_move_path, item)
                                    if eachfile != target:
                                        shutil.move(eachfile, target)
                                        ret['move_path'] = target
                            elif ret['ret'] == "fail":
                                if SMI2SRTHandle.fail_move_path != "":
                                    target = os.path.join(
                                        SMI2SRTHandle.fail_move_path, item)
                                    if eachfile != target:
                                        shutil.move(eachfile, target)
                                        ret['move_path'] = target
                            elif ret['ret'] == "continue":
                                continue
                            elif ret['ret'] == "not_smi_is_ass":
                                shutil.move(eachfile,
                                            srt_file.replace('.srt', '.ass'))
                                ret['move_path'] = srt_file.replace(
                                    '.srt', '.ass')
                                log_debug("move to ass..")
                            elif ret['ret'] == "not_smi_is_srt":
                                shutil.move(eachfile, srt_file)
                                ret['move_path'] = srt_file
                                log_debug("move to srt..")
                            #elif ret['ret'] == "not_smi_is_torrent":
                            #    shutil.move(eachfile, eachfile.replace('.smi', '.torrent'))
                            #    log_debug("move to torrent..")
                            SMI2SRTHandle.result_list['list'].append(ret)
                        elif eachfile[-7:].lower() == '.ko.srt' or eachfile[
                                -8:].lower() == '.kor.srt' or (
                                    eachfile[-7] == '.'
                                    and eachfile[-4:].lower() == '.srt'):
                            #log_debug("pass : %s", eachfile)
                            pass
                        elif eachfile[-4:].lower() == '.srt':
                            if not SMI2SRTHandle.no_change_ko_srt:
                                log_debug(".srt => .ko.srt : %s", eachfile)
                                # 2020-06-15 한글이 들어있는 파일만.
                                # 할 필요있나?..
                                shutil.move(
                                    eachfile,
                                    eachfile.replace('.srt', '.ko.srt'))
                except Exception as e:
                    log_debug('Exception:%s', e)
                    log_debug(traceback.format_exc())

        except Exception as e:
            log_debug('Exception:%s', e)
            log_debug(traceback.format_exc())
Example #18
0
 def create_gd_entity(info):
     try:
         entity = ModelTvMvItem(info['name'], info['folder_id'], info['rule_name'], info['rule_id'])
         if entity == None: return None
         entity.rule_name = py_unicode(info['rule_name'])
         entity.agent_type = py_unicode(info['agent_type'])
         entity.root_folder_id = py_unicode(info['root_folder_id'])
         entity.target_folder_id = py_unicode(info['target_folder_id'])
         entity.mime_type = py_unicode(info['mime_type'])
         entity.parent_folder_id = py_unicode(info['parent_folder_id'])
         entity.code = py_unicode(info['code'])
         entity.status = info['status']
         entity.title = py_unicode(info['title'])
         entity.site = py_unicode(info['site'])
         entity.studio = py_unicode(info['studio'])
         entity.poster_url = py_unicode(info['poster_url'])
         entity.year = info['year']
         entity.genre = info['genre']
         entity.country = py_unicode(info['country'])
         entity.save()
         return entity
     
     except Exception as e:
         logger.debug('Exception:%s', e)
         logger.debug(traceback.format_exc())
Example #19
0
    def check_move_list(item, ktv_drama_target_path, ktv_show_target_path, movie_target_path, error_target_path):
        ktv_show_genre_flag = ModelSetting.get_bool('ktv_show_genre_flag')
        try:
            weight_con = 0
            season_con = re.compile('(s|S)+\d?\d')
            if season_con.search(item['name']):
                weight_con += 1
            episode_con = re.compile('(e|E)+\d?\d?\d')
            if episode_con.search(item['name']):
                weight_con += 1
            logger.debug('cml - weight:%s', weight_con)
            #TV Show
            if 'episode' in item['guessit'] and item['guessit']['type'] == 'episode' and weight_con > 0:
                from .api_daum_tv import DaumTV
                #from framework.common.daum import DaumTV
                logger.debug('cml - drama %s, %s, %s', item['name'], item['search_name'], item['guessit']['title'])
                tmp_title_0 = item['guessit']['title']
                tmp_title_1 = item['search_name']
                tmp_title_1 = re.sub('(e|E)+\d\d?\d\d?', '', tmp_title_1)
                tmp_title_1 = re.sub('(e|E)+(n|N)+(d|D)', '', tmp_title_1)
                if tmp_title_0.isalpha and LogicNormal.isHangul(tmp_title_0) > 0:
                  #title_tmp = re.sub('[A-Za-z0-9._]', '', tmp_title_0)
                  title_tmp = re.sub(r'\[[^)]*\]', '', tmp_title_0)
                  title_tmp = py_unicode(title_tmp.strip())
                  item['guessit']['title'] = title_tmp
                  logger.debug('cml - title_check:%s', title_tmp)

                daum_tv_info = DaumTV.get_daum_tv_info(item['guessit']['title'])
                if daum_tv_info is not None:
                  LogicNormal.set_ktv(item, daum_tv_info)
                  if item['dest_folder_name'] != item['guessit']['title']:
                    if tmp_title_1.isalpha and LogicNormal.isHangul(tmp_title_1) > 0:
                      #title_tmp = re.sub('[A-Za-z0-9._]', '', tmp_title_0)
                      title_tmp = re.sub(r'\[[^)]*\]', '', tmp_title_1)
                      title_tmp = py_unicode(title_tmp.strip())
                      item['guessit']['title'] = title_tmp
                      logger.debug('cml - title_check:%s', title_tmp)
                      daum_tv_info = DaumTV.get_daum_tv_info(item['guessit']['title'])
                #daum_tv_info = DaumTV.get_daum_tv_info(item['search_name'])
                if daum_tv_info is not None:
                    if daum_tv_info['genre'] == u'드라마':
                        logger.debug('cml - korea drama %s', daum_tv_info['genre'])
                        LogicNormal.set_ktv(item, daum_tv_info)
                        LogicNormal.move_ktv_drama(item, daum_tv_info, ktv_drama_target_path)
                    elif ktv_show_genre_flag == 1:
                        logger.debug('cml - korea show genre %s', daum_tv_info['genre'])
                        LogicNormal.set_ktv(item, daum_tv_info)
                        LogicNormal.move_ktv_show_genre(item, daum_tv_info, ktv_show_target_path)
                    elif ktv_show_target_path is not None and ktv_show_genre_flag == 0:
                        logger.debug('cml - korea show %s', daum_tv_info['genre'])
                        LogicNormal.set_ktv(item, daum_tv_info)
                        LogicNormal.move_ktv_show(item, daum_tv_info, ktv_show_target_path)
                    else:
                        LogicNormal.move_except(item, error_target_path)
                else:
                    LogicNormal.move_except(item, error_target_path)
            #Movie
            else:
                from .api_daum_movie import MovieSearch
                #from framework.common.daum import MovieSearch
                logger.debug('cml - movie %s', item['name'])
                if 'year' not in item['guessit']:
                  for cy_name in item['name'].splitlines():
                    try:
                      tmp_year = re.search('\d{4}', cy_name).group(0)
                    except:
                      tmp_year = re.search('\d{4}', cy_name)
                    if int(tmp_year) > 1900:
                      item['guessit']['year'] = tmp_year
                if 'year' in item['guessit']:
                    logger.debug('cml - movie %s year %s', item['name'], item['guessit']['year'])
                    (item['is_include_kor'], daum_movie_info) = MovieSearch.search_movie(item['search_name'], item['guessit']['year'])
                    if (daum_movie_info and daum_movie_info[0]['score'] >= 100):
                        logger.debug('cml - movie score %s', daum_movie_info[0]['score'])
                        #logger.debug('cml - rate : %s', daum_movie_info[0]['more']['rate'])
                        LogicNormal.set_movie(item, daum_movie_info[0])
                        LogicNormal.move_movie(item, daum_movie_info[0], movie_target_path)
                    elif daum_movie_info and daum_movie_info[0]['score'] >= 90:
                        logger.debug('cml - movie score %s', daum_movie_info[0]['score'])
                        if 'more' in daum_movie_info[0]:
                            if'eng_title' in daum_movie_info[0]['more']:
                                logger.debug('cml - movie %s:%s', item['guessit']['title'], daum_movie_info[0]['more']['eng_title'])
                                #if LogicNormal.isHangul(str_cmp_0) > 0:
                                    #korean = re.compile('[\u3130-\u318F\uAC00-\uD7A3]+')
                                str_cmp_0 = re.sub('[^A-Za-z0-9\s]', '', item['guessit']['title'])
                                str_cmp_0 = py_unicode(str_cmp_0.strip())
                                str_cmp_1 = daum_movie_info[0]['more']['eng_title']
                                str_cmp_1 = py_unicode(str_cmp_1)
                                logger.debug('cml - movie cmp %s:%s', str_cmp_0.lower(), str_cmp_1.lower())
                                if str_cmp_0.lower() == str_cmp_1.lower():
                                    logger.debug('cml - movie file name checked!')
                                    LogicNormal.set_movie(item, daum_movie_info[0])
                                    LogicNormal.move_movie(item, daum_movie_info[0], movie_target_path)
                                else:
                                     LogicNormal.move_except(item, error_target_path)
                            else:
                                 LogicNormal.move_except(item, error_target_path)
                        else:
                             LogicNormal.move_except(item, error_target_path)
                    else:
                        LogicNormal.move_except(item, error_target_path)
                else:
                    logger.debug('cml - movie NOT have year!')
                    LogicNormal.move_except(item, error_target_path)
        except Exception as e:
            logger.error('Exxception:%s', e)
            logger.error(traceback.format_exc())
Example #20
0
 def __init__(self, name, entity_id, agent_type, sub_type):
     self.created_time = datetime.now()
     self.name = py_unicode(name)
     self.entity_id = entity_id
     self.sub_type = sub_type
     self.agent_type = py_unicode(agent_type)
Example #21
0
 def __init__(self, string, integer, boolean, imgurl):
     self.created_time = datetime.now()
     self.sample_string = py_unicode(string)
     self.sample_integer = integer
     self.sample_boolean = boolean
     self.sample_imgurl = imgurl