Ejemplo n.º 1
0
def Detail(
        no,  # String(In): FileID
        user  # String(In): User Name
):  # String(html)
    global lock
    global conn
    global c
    global videoInfo

    # [[[ 1. Lock ]]]
    lock.acquire()

    # [[[ 2. Prepare SQLite ]]]
    if conn is None:
        conn = sqlite3.connect(fileName, check_same_thread=False)
        c = conn.cursor()

    # [[[ 3. Make <li></li> List ]]]
    list = ''  # return html string
    # [[ 3.1. Prepare SQL statement ]]
    sql = 'SELECT FileID, DirName, FileName, Size, Time FROM File WHERE FileID = ?'
    # [[ 3.2. Query ]]
    size = 0
    time = ''
    filePath = ''
    for row in c.execute(sql, [no]):
        size = row[3]
        time = row[4]
        filePath = os.path.join(row[1], row[2])

    # [[[ 4. Unlock ]]]
    lock.release()

    # [[[ 5. Make Tag ]]]
    list = filePath + "<br>" + "{:,}".format(size) + "[Byte]<br>"
    list = list + time + "<br>"
    if None is videoInfo:
        videoInfo = VideoInfo.VideoInfo()
    if (None is videoInfo.GetDuration(filePath)):
        list = u"動画が見つかりません。" + "<br>" + u"曲情報を更新してください。"
    else:
        hour = str(int(videoInfo.GetDuration(filePath) / 3600)).zfill(2)
        minutes = str(int(videoInfo.GetDuration(filePath) % 3600 /
                          60)).zfill(2)
        seconds = str(int(videoInfo.GetDuration(filePath) % 60)).zfill(2)
        list = list + hour + ":" + minutes + ":" + seconds + "<br>"
        list = list + videoInfo.GetVideoEncode(filePath) + "("
        list = list + videoInfo.GetResolution(filePath) + ")"
        # [[ 5.1. History Count ]]
        list = list + "<br>" + str(History.Count(filePath)) + u"回"

    return list
Ejemplo n.º 2
0
def Search(keywords, user, page):  # string with <li></li> elements
    global lock
    global conn
    global c

    # [[[ 1. Lock ]]]
    lock.acquire()

    # [[[ 2. Check DB File ]]]
    if not os.path.exists("." + os.path.sep + fileName):
        # < File not Exists >
        lock.release()
        return ""

    # [[[ 3. Prepare SQLite ]]]
    if conn is None:
        conn = sqlite3.connect(fileName, check_same_thread=False)
        c = conn.cursor()

    # [[[ 4. Make <li></li> List ]]]
    list = ''  # return html string
    # [[ 4.1. Prepare SQL statement ]]
    sql = 'SELECT FileID, FileName, DirName FROM File WHERE '
    isMultiKeyword = 0
    keywords = keywords.strip()
    param = []
    if keywords == "":
        # < All List >
        sql = 'SELECT FileID, FileName, DirName FROM File'
    else:
        # < Search List >
        for keyword in keywords.split():
            if 1 == isMultiKeyword:
                sql = sql + " AND "
            sql = sql + \
              '(DirName LIKE ? OR FileName LIKE ?)'
            isMultiKeyword = 1
            param = param \
              + [ "%" + keyword + "%" , "%" + keyword + "%" ]
    sql = sql + " ORDER BY FileName ASC LIMIT " + str(limit)
    sql = sql + " OFFSET " + str(limit * (int(page) - 1))
    # [[ 4.2. Query ]]
    for row in c.execute(sql, param):
        filePath = os.path.join(row[2], row[1])
        if 0 != History.Count(filePath):
            # < Already Play >
            list = list + \
              "<li><a class=\"ui-btn ui-icon-check ui-btn-icon-left\" " + \
              "href=\"detail?fileId=" + str(row[0]) + \
              "&user="******"&keyword=" + keywords + \
              "&page=" + page + "\" rel=\"external\"><font style=\"white-space:normal;\">" + \
              row[1] + "</font></a></li>"
        else:
            # < Not Play >
            list = list + \
              "<li><a " + \
              "href=\"detail?fileId=" + str(row[0]) + \
              "&user="******"&keyword=" + keywords + \
              "&page=" + page + "\" rel=\"external\"><font style=\"white-space:normal;\">" + \
              row[1] + "</font></a></li>"

    # [[[ 5. Unlock ]]]
    lock.release()

    return list