Exemplo n.º 1
0
 def  create(self, file_path):
     processor = fileprocessor.FileProcessor(file_path)
     video = Video("", processor.name, int(processor.size), processor.md5)
     client = pyVideoClient.pyVideoClient()
     ret = client.createVideo(video)
     if ret == None:
         return None
     return ret["id"]
Exemplo n.º 2
0
    def test_video(self):
        client = pyVideoClient.pyVideoClient()
        videos = client.getVideoList()
        if len(videos) == 0:
            return
        pdb.set_trace()
        video = videos[0]
        state = video['state']

        client.updateVideoState(video['id'], state+1)
        new_video = client.getVideo(video['id'])
        print("old state is {0}, and new state is {1}".format(state, new_video['video']['state']))
Exemplo n.º 3
0
    def get_storage_info(self):
        result = []
        client = pyVideoClient.pyVideoClient()
        storages = client.getStorageInfo()
        for s in storages:
            storage = Storage(s["id"], s["name"], s["container"], s["key"])
            result.append(storage)
        # cnx = mysql.connector.connect(**self.__config)
        # cursor = cnx.cursor()

        # query = ("SELECT s.id, s.name, s.container, s.key FROM storages s")

        # cursor.execute(query)
        # for (id, name, container, key) in cursor:
        #     storage = Storage(id, name, container, key)
        #     result.append(storage)

        # cursor.close()
        # cnx.close()
        return result
Exemplo n.º 4
0
    def list(self):
        result = []
        client = pyVideoClient.pyVideoClient()
        videos = client.getVideoList()
        for v in videos:
            video = Video(v["id"], v["name"], v["size"], v["md5"])
            result.append(video)
        # cnx = mysql.connector.connect(**self.__config)
        # cursor = cnx.cursor()

        # query = ("SELECT id, name, size, md5 FROM videos order by name")
        # cursor.execute(query)
        
        # for (id, name, size, md5) in cursor:
        #     video = Video(id, name, size, md5)
        #     result.append(video)

        # cursor.close()
        # cnx.close()
        return result
Exemplo n.º 5
0
    def get(self, id):
        result = None
        client = pyVideoClient.pyVideoClient()
        storages = client.getStorageInfo()

        data = client.getVideo(id)
        if data == None:
            return None


        video_data = data["video"]
        vf_data = data["video_files"]
        video = Video(video_data["id"], video_data["name"], video_data["size"], video_data["md5"])
        video_details = VideoDetails(video)

        for f in vf_data:
            for s in storages:
                if s["id"] == f["storageid"]:
                    chunck = Chunck(f["index"], f["path"], s["name"], s["container"], s["key"])
                    video_details.append_chunck(chunck)
                    break

        return video_details
Exemplo n.º 6
0
 def test_create_video(self):
     client = pyVideoClient.pyVideoClient()
     video = videostoreoperator.Video('', 'api test', 1010, 'hello api')
     ret = client.createVideo(video)
     print(ret)
Exemplo n.º 7
0
 def test_storage_get(self):
     client = pyVideoClient.pyVideoClient()
     storages = client.getStorageInfo()
     for s in storages:
         print("id={0}, name={1}, container={2}, key={3}".format(s["id"], s["name"], s["container"], s["key"]))
Exemplo n.º 8
0
 def updateState(self, id, new_state):
     client = pyVideoClient.pyVideoClient()
     ret = client.updateVideoState(id, new_state)
     return ret
Exemplo n.º 9
0
 def delete(self, id):
     client = pyVideoClient.pyVideoClient()
     client.deleteVideo(id)