Example #1
0
def updateMovieMagnet2(avNumber, magnet):
    #print(avNumber + ": " + magnet)
    conn = SysConst.getConnect()
    conn.execute("update t_movies set magnet=? where av_number=?",
                 [magnet, avNumber])
    conn.commit()
    conn.close()
Example #2
0
def predict():
    conn = SysConst.getConnect()
    movies = SimilarDAO.getAllBaseMovies(conn)
    allTargetMovies = {}
    for movie in movies:
        base = movie["av_number"]
        allMovies = SimilarDAO.getSimilarsByBase(base, conn)
        i = 0
        for movie in allMovies:
            i += 1
            if movie["target"] in allTargetMovies:
                allTargetMovies[
                    movie["target"]] = i + allTargetMovies[movie["target"]]
            else:
                allTargetMovies[movie["target"]] = i
    conn.close()

    list = []
    for name in allTargetMovies:
        list.append({"av_number": name, "similar": allTargetMovies[name]})

    list = sorted(list, key=lambda d: d["similar"], reverse=False)
    list = list[0:50]

    numberList = []
    for one in list:
        numberList.append(one["av_number"])

    return numberList


#print(predict())
Example #3
0
def getAllActors():
    conn = SysConst.getConnect()
    yesterday = round(time.time() - 24 * 60 * 60)
    lastweek = round(time.time() - 24 * 60 * 60 * 3)
    # print(yesterday)
    cursor = conn.execute(
        "SELECT name, url, short_name from t_actors where "
        " (favor = 1 and last_read_time < ?) "
        " or (favor = 0 and last_read_time < ?)"
        " or last_read_time is null"
        " order by favor desc, last_read_time desc", [yesterday, lastweek])

    results = []

    for row in cursor:
        url = row[1]

        # domain change to nanrenvip.co
        #url = url.replace("www.nh87.cn", "nanrenvip.net")
        url = url.replace("www.nh87.cn", "nanrenvip.co")
        url = url.replace("nanrenvip.net", "nanrenvip.co")
        url = url.replace("nanrenvip.co", "nanrenvip.org")

        one = {"name": row[0], "url": url, "short_name": row[2]}
        results.append(one)

    conn.close()

    return results
Example #4
0
def tagTrash():
    vrPath = SysConst.getTextPath()
    movieFiles = DiskIndex.getTxts(vrPath)
    allNumbers = DownloadDAO.get_all_download()

    conn = SysConst.getConnect()

    for avNumber in allNumbers:
        name = avNumber.lower()
        first = name[0:name.find('-')]
        second = name[name.find('-') + 1:]
        for file in movieFiles:
            filename = file["filename"].lower()
            if filename.find(first) > -1 and filename.find(second) > -1:
                print("find " + name + " : " + file["fullpath"])
                movieFiles.remove(file)

                av = {
                    "av_number": avNumber.upper(),
                    "local": 0,
                    "classic": 0,
                    "vr": 0,
                    "trash": 1
                }
                DownloadDAO.mark_download(conn, av)

                break

    conn.commit()
    conn.close()
Example #5
0
def forcast():
    Log.info("do forcast")
    localBayes = bayes.BayesTrainingFromDB("local")
    vrBayes = bayes.BayesTrainingFromDB("vr")
    skipBayes = bayes.BayesTrainingFromDB("skip")
    trashBayes = bayes.BayesTrainingFromDB("trash")

    movies = MovieDAO.getMoviesByCondition(
        "local = 0 and trash = 0 and skip = 0")

    conn = SysConst.getConnect()
    for movie in movies:
        token = movie["av_number"] + movie["actor"] + movie["title"]
        # token = movie["av_number"] + movie["title"]
        local = localBayes.probable(token)
        vr = vrBayes.probable(token)
        skip = skipBayes.probable(token)
        trash = trashBayes.probable(token)

        #movie["vr_forcast"] = local + vr
        forcast = round((vr - skip * 0.4 - trash * 0.01 + local * 0.3) * 10000)
        MovieDAO.updateMovieVRForcast(movie["av_number"], forcast, conn)

    conn.commit()
    conn.close()
Example #6
0
def updateLastReadTime(name):
    conn = SysConst.getConnect()
    now = round(time.time())

    cursor = conn.cursor()
    cursor.execute("update t_actors set last_read_time = ? where name = ?",
                   [now, name])

    conn.commit()
    conn.close()
Example #7
0
def updateMovieLastReadTime(avNumber):
    conn = SysConst.getConnect()
    now = round(time.time())

    cursor = conn.cursor()
    cursor.execute(
        "update t_movies set last_read_time = ? where av_number = ?",
        [now, avNumber])

    conn.commit()
    conn.close()
Example #8
0
def getUndownloadMagnets():
    #images = DiskIndex.getAllImages(SysConst.getImageTempPath())
    conn = SysConst.getConnect()
    movies = MovieDAO.getMoviesByCondition(
        "local = 2 and download = 0 and magnet is not null and (read != 1 or read is null) order by create_time limit 20"
    )
    for movie in movies:
        print(movie["magnet"])
        MovieDAO.updateMovieReaded(movie["av_number"], conn)

    conn.commit()
    conn.close()
Example #9
0
def get_all_download():
    conn = SysConst.getConnect()
    cursor = conn.execute(
        "SELECT av_number from t_download where local != 1 and trash != 1")

    results = []
    for row in cursor:
        results.append(row[0])

    conn.close()

    return results
Example #10
0
def calcMovie(movie, allImages):
    try:
        actor = movie["actor"]
        conn = SysConst.getConnect()
        basePath = SysConst.getImageCachePath() + actor + "//" + movie["av_number"] + ".jpg";

        if not os.path.exists(basePath):
            print("can not find file: " + basePath)
            return

        base = movie["av_number"]
        targetMap = getTargetMap(base, conn)
        print("compare " + actor + "/" + base)
        count = 0
        skipCount = 0

        for image in allImages:
            targetPath = image["fullpath"]
            target = image["filename"][0:-4]
            # exist = SimilarDAO.hasSimilar(base, target, conn)
            if not target in targetMap:
                # print(targetPath)
                count += 1

                if count % 500 == 0:
                    print("calc " + str(count))
                    conn.commit()
                    conn.close()
                    conn = SysConst.getConnect()

                similar = ImageSimilar.calc_similar_by_path(basePath, targetPath)
                obj = {"base": base, "target": target, "similar": similar}
                SimilarDAO.saveSimilar(obj, conn)
            else:
                skipCount += 1

        print("count: " + str(count) + ", skip: " + str(skipCount))
    finally:
        conn.commit()
        conn.close()
Example #11
0
def copyWrongMagnets():
    movies = MovieDAO.getMoviesByCondition(
        "local = 2 and download = 0 and magnet is not null")

    conn = SysConst.getConnect()
    try:
        for movie in movies:
            WrongMagnetDAO.saveMagnet(movie, conn)
    except Exception as err:
        print(err)
    finally:
        conn.commit()
        conn.close()
Example #12
0
def saveActors(actors):
    newActors = []
    conn = SysConst.getConnect()

    for actor in actors:
        exist = saveActor(actor, conn)
        if not exist:
            newActors.append(actor)

    conn.commit()
    conn.close()

    return newActors
Example #13
0
def findWrongMagnets(avNumber):
    conn = SysConst.getConnect()

    cursor = conn.execute(
        "SELECT magnet, create_time from t_wrong_magnets where av_number = ?",
        [avNumber])

    results = []
    for row in cursor:
        results.append(row[0])

    conn.close()

    return results
Example #14
0
def getFavorActors():
    conn = SysConst.getConnect()
    yesterday = round(time.time() - 24 * 60 * 60)
    # print(yesterday)
    cursor = conn.execute("SELECT * from t_actors where favor = 1")

    results = []
    for row in cursor:
        one = {"name": row[0], "url": row[1]}
        results.append(one)

    conn.close()

    return results
Example #15
0
def getAllActorsFully():
    conn = SysConst.getConnect()
    # print(yesterday)
    cursor = conn.execute(
        "SELECT name, url, short_name from t_actors "
        " order by favor desc, last_read_time desc", [])

    results = []
    for row in cursor:
        one = {"name": row[0], "url": row[1], "short_name": row[2]}
        results.append(one)

    conn.close()

    return results
Example #16
0
def updateShortName():
    conn = SysConst.getConnect()
    # print(yesterday)
    cursor = conn.execute("SELECT name, url from t_actors", [])
    results = []
    for row in cursor:
        one = {"name": row[0], "url": row[1]}
        results.append(one)

    cursor = conn.cursor()

    for row in results:
        shortName = substr1(row["url"])
        print(shortName)
        cursor.execute("update t_actors set short_name = ? where name = ?",
                       [shortName, row["name"]])
    conn.commit()
    conn.close()
Example #17
0
def tagDownload():
    path = SysConst.getDownloadPath()
    movieFiles = DiskIndex.getTxts(path)
    allNumbers = DownloadDAO.get_all_download()

    conn = SysConst.getConnect()

    for avNumber in allNumbers:
        name = avNumber.lower()
        first = name[0:name.find('-')]
        second = name[name.find('-') + 1:]
        for file in movieFiles:
            filename = file["filename"].lower()
            if filename.find(first) > -1 and filename.find(second) > -1:
                print("find " + name + " : " + file["fullpath"])
                movieFiles.remove(file)
                MovieDAO.markMovieDownload(conn, avNumber.upper())
                break

    conn.commit()
    conn.close()
Example #18
0
    conn.close()

    return results


def mark_download(conn, av):
    cursor = conn.cursor()

    av_number = av["av_number"]
    local = av.get("local")
    classic = av.get("classic")
    vr = av.get("vr")
    trash = av.get("trash")

    cursor.execute(
        "update t_download set local=?,classic=?,vr=?,trash=? where av_number=?",
        [local, classic, vr, trash, av_number])


if __name__ == '__main__':
    av = {
        "av_number": "CEMN-004",
        "local": 0,
        "classic": 0,
        "vr": 0,
        "trash": 1
    }

    with SysConst.getConnect() as conn:
        mark_download(conn, av)
Example #19
0
def getConnect():
    return SysConst.getConnect()