Пример #1
0
def console():
    global path
    global user
    global comment
    global pause
    global duration
    global audioNum

    # [[[ 1. Update Playing Video ]]]
    if 0 != len(Book.List()) and False is pause:
        # < Can Play >
        if False is video.CheckPlaying():
            # < Not Playing >
            # [[ 1.1. Lock ]]
            lock.acquire()
            try:
                # [[ 1.2. Get and Update First Reservation ]]
                bookList = Book.List()[0]
                path = bookList[2]
                user = bookList[3]
                comment = bookList[4]
                dummy = bookList[8]
                audioIndex = int(bookList[7])
                duration = videoInfo.GetDuration(path)
                audioNum = videoInfo.GetAudioNum(path)
                # [[ 1.2. Check Dummy ]]
                if 0 == dummy:
                    # < Not Dummy >
                    # [ 1.2.1. Play Video ]
                    video.Open(path, vol, audioNum, audioIndex)
                    # [ 1.2.2. Add History ]
                    History.Add(path, user, comment)
                    # [ 1.2.3. Update pause status for playing ]
                    pause = False
                else:
                    # < Dummy >
                    # [ 1.2.4. Switch HDMI Signal ]
                    hdmi.Switch()
                    # [ 1.2.5. Update pause status for pausing ]
                    pause = True
            except:
                import traceback
                traceback.print_exc()
            finally:
                # [[ 1.3. Delete Playing Book ]]
                Book.Delete(bookList[0])
                # [[ 1.4. Unlock ]]
                lock.release()
Пример #2
0
def checkdup():
    directoryPath, fileName = File.Get(request.query.fileId)
    if directoryPath[-1] is not os.path.sep:
        directoryPath = directoryPath + os.path.sep
    for book in Book.List():
        if directoryPath + fileName == book[2]:
            return "{\"dup\":true}"
    return "{\"dup\":false}"
Пример #3
0
def playlist():
    list = '['
    firstLine = True
    for row in Book.List():
        if False == firstLine:
            list = list + ","
        firstLine = False
        list = list + "{\"id\":" + str(row[0]) + ","
        list = list + "\"user\":\"" + row[3] + "\","
        if 1 == row[5]:
            list = list + "\"song\":\"" + os.path.basename(row[2]) + "\","
        else:
            list = list + u"\"song\":\"非公開\","
        list = list + "\"comment\":\"" + row[4] + "\"}"
    return list + "]"