1
- import webbrowser as web
1
+ from typing import Optional
2
+ from videodb ._utils .video import play_url
2
3
from videodb ._constants import (
3
4
ApiPath ,
4
5
SearchType ,
7
8
)
8
9
from videodb .search import SearchFactory , SearchResult
9
10
from videodb .shot import Shot
10
- from typing import Optional
11
11
12
12
13
13
class Video :
14
14
def __init__ (self , _connection , id : str , collection_id : str , ** kwargs ) -> None :
15
15
self ._connection = _connection
16
16
self .id = id
17
17
self .collection_id = collection_id
18
- self .stream_url = kwargs .get ("stream_link " , None )
19
- self .player_url = kwargs .get ("player_link " , None )
18
+ self .stream_url = kwargs .get ("stream_url " , None )
19
+ self .player_url = kwargs .get ("player_url " , None )
20
20
self .name = kwargs .get ("name" , None )
21
21
self .description = kwargs .get ("description" , None )
22
- self .thumbnail_url = kwargs .get ("thumbnail " , None )
22
+ self .thumbnail_url = kwargs .get ("thumbnail_url " , None )
23
23
self .length = float (kwargs .get ("length" , 0.0 ))
24
24
self .transcript = kwargs .get ("transcript" , None )
25
25
self .transcript_text = kwargs .get ("transcript_text" , None )
@@ -84,8 +84,8 @@ def generate_stream(self, timeline: Optional[list[tuple[int, int]]] = None) -> s
84
84
"length" : self .length ,
85
85
},
86
86
)
87
- self .stream_url = stream_data .get ("stream_link " )
88
- self .player_url = stream_data .get ("player_link " )
87
+ self .stream_url = stream_data .get ("stream_url " )
88
+ self .player_url = stream_data .get ("player_url " )
89
89
return self .stream_url
90
90
91
91
def generate_thumbnail (self ):
@@ -94,7 +94,7 @@ def generate_thumbnail(self):
94
94
thumbnail_data = self ._connection .get (
95
95
path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .thumbnail } "
96
96
)
97
- self .thumbnail_url = thumbnail_data .get ("thumbnail " )
97
+ self .thumbnail_url = thumbnail_data .get ("thumbnail_url " )
98
98
return self .thumbnail_url
99
99
100
100
def _fetch_transcript (self , force : bool = False ) -> None :
@@ -137,8 +137,8 @@ def add_subtitle(self) -> str:
137
137
"type" : Workflows .add_subtitles ,
138
138
},
139
139
)
140
- self .stream_url = subtitle_data .get ("stream_link " )
141
- self .player_url = subtitle_data .get ("player_link " )
140
+ self .stream_url = subtitle_data .get ("stream_url " )
141
+ self .player_url = subtitle_data .get ("player_url " )
142
142
return self .stream_url
143
143
144
144
def insert_video (self , video , timestamp : float ) -> str :
<
ACBE
tr class="diff-line-row">@@ -178,16 +178,15 @@ def insert_video(self, video, timestamp: float) -> str:
178
178
for shot in all_shots
179
179
],
180
180
)
181
- self .stream_url = compile_data .get ("stream_link " )
182
- self .player_url = compile_data .get ("player_link " )
181
+ self .stream_url = compile_data .get ("stream_url " )
182
+ self .player_url = compile_data .get ("player_url " )
183
183
return self .stream_url
184
184
185
185
def play (self ) -> str :
186
- """Generate a stream url for the shot and open it in the default browser
186
+ """Open the player url in the browser/iframe and return the stream url
187
187
188
188
:return: The stream url
189
189
:rtype: str
190
190
"""
191
- self .generate_stream ()
192
- web .open (self .player_url )
191
+ play_url (self .player_url )
193
192
return self .player_url
0 commit comments