1- import webbrowser as web
1+ from typing import Optional
2+ from videodb ._utils .video import play_url
23from videodb ._constants import (
34 ApiPath ,
45 SearchType ,
78)
89from videodb .search import SearchFactory , SearchResult
910from videodb .shot import Shot
10- from typing import Optional
1111
1212
1313class Video :
1414 def __init__ (self , _connection , id : str , collection_id : str , ** kwargs ) -> None :
1515 self ._connection = _connection
1616 self .id = id
1717 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 )
2020 self .name = kwargs .get ("name" , None )
2121 self .description = kwargs .get ("description" , None )
22- self .thumbnail_url = kwargs .get ("thumbnail " , None )
22+ self .thumbnail_url = kwargs .get ("thumbnail_url " , None )
2323 self .length = float (kwargs .get ("length" , 0.0 ))
2424 self .transcript = kwargs .get ("transcript" , None )
2525 self .transcript_text = kwargs .get ("transcript_text" , None )
@@ -84,8 +84,8 @@ def generate_stream(self, timeline: Optional[list[tuple[int, int]]] = None) -> s
8484 "length" : self .length ,
8585 },
8686 )
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 " )
8989 return self .stream_url
9090
9191 def generate_thumbnail (self ):
@@ -94,7 +94,7 @@ def generate_thumbnail(self):
9494 thumbnail_data = self ._connection .get (
9595 path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .thumbnail } "
9696 )
97- self .thumbnail_url = thumbnail_data .get ("thumbnail " )
97+ self .thumbnail_url = thumbnail_data .get ("thumbnail_url " )
9898 return self .thumbnail_url
9999
100100 def _fetch_transcript (self , force : bool = False ) -> None :
@@ -137,8 +137,8 @@ def add_subtitle(self) -> str:
137137 "type" : Workflows .add_subtitles ,
138138 },
139139 )
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 " )
142142 return self .stream_url
143143
144144 def insert_video (self , video , timestamp : float ) -> str :
@@ -178,16 +178,15 @@ def insert_video(self, video, timestamp: float) -> str:
178178 for shot in all_shots
179179 ],
180180 )
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 " )
183183 return self .stream_url
184184
185185 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
187187
188188 :return: The stream url
189189 :rtype: str
190190 """
191- self .generate_stream ()
192- web .open (self .player_url )
191+ play_url (self .player_url )
193192 return self .player_url
0 commit comments