예제 #1
0
파일: aBak.py 프로젝트: phil1988132/VEDIO
def main():
    translator = GoogleTranslator()
    count = 0
    with open('C:\\dx\\python\\d.txt', 'w', encoding='utf-8') as df:
        for line in readFile('C:\\dx\\python\\s.txt'):
            if len(line) > 1:
                count += 1
                print('\r' + str(count), end='', flush=True)
                df.write(line.strip() + "\n")
                result = translator.translate(line)
                df.write(result.strip() + "\n\n")
예제 #2
0
def poolDetail(start, end):
    getObj = videoDemo()
    dbObj = Dbobj('redio', 're_')
    arr = []
    # if type == 0:
    #    _sort = pymongo.DESCENDING
    # else:
    #    _sort = pymongo.ASCENDING
    curTableObj = dbObj.getTbname('redios')
    base = 'https://www.qq.com/'
    while True:
        data = curTableObj.find({
            "status": 0,
            "_id": {
                "$gte": start,
                "$lt": end
            }
        }).sort('_id', pymongo.DESCENDING).limit(10)
        #_count = len(data)
        #pool = Pool(_count)
        if data is None:
            break
        g = GoogleTranslator()
        for v in data:
            curUrl = base + v['rel'].strip('/')
            #curTableObj.run(curUrl,i['id'])
            #curUrl='https://www.qq.com/video13860839/502_-_horny_asian_couple_had_sex_on_bed'
            tags = getObj.vdetail(curUrl, v['id'])

            v['title'] = v['title'].replace('&#039', '').replace('&', '')

            s = g.translate(v['title'])
            _curUpData = {}
            if s == '':
                _curUpData['status'] = 3
            else:
                _curUpData['status'] = 1
                _curUpData['ctitle'] = s
            if tags != False:
                _curUpData['tags'] = tags
            data = curTableObj.update({"id": v['id']}, {"$set": _curUpData})
        time.sleep(0.5)
예제 #3
0
파일: dTrans.py 프로젝트: phil1988132/VEDIO
def pTrans(curTableObj, curPage):
    skip = (curPage - 1) * 10000
    data = curTableObj.find({
        "status": 1,
        "ctitle": ""
    }).sort('_id', pymongo.ASCENDING).limit(10000).skip(skip)
    i = 0
    for v in data:
        translator = GoogleTranslator()
        title = v['title'].strip('/').replace('&#039', '').replace('&', '')
        #print(title)
        tags = trans(translator, title)
        #print(tags);exit('3')
        if tags == '':
            curTableObj.update({"id": v['id']}, {"$set": {"status": 3}})
        else:
            curTableObj.update({"id": v['id']}, {"$set": {"ctitle": tags}})
        i += 1
        if i % 10:
            time.sleep(0.3)
예제 #4
0
파일: del.py 프로젝트: phil1988132/VEDIO
import sys
sys.path.append('..')
from commone.GoogleTranslator import GoogleTranslator
import time
from Dbobj import Dbobj
import pymongo

if __name__ == "__main__":
    startTime = time.time()
    dbObj = Dbobj('redio', 're_')
    arr = []
    curTableObj = dbObj.getTbname('tags')
    newRe = _re = []
    data = curTableObj.find({
        "cname": ""
    }).sort('_id', pymongo.ASCENDING).limit(1000)
    j = 0
    g = GoogleTranslator()
    for v in data:

        #v['title']=v['title'].replace('&#039','').replace('&','')

        s = ctitle = g.translate(v['name'])
        curTableObj.update({"_id": v['_id']}, {"$set": {"cname": ctitle}})
        if j % 10:
            time.sleep(0.5)