Exemple #1
0
 def check_type(part):
     nessery_keys = ['sound', 'end time']
     if not isinstance(part, dict):
         msg = '''Video.get_nextsound must return 'dict' argument,
               type({}) = {} were given'''.format(part, type(part))
         raise TypeError(str_to_error_message(msg))
     for key in nessery_keys:
         if not key in part:
             msg = '''VideoStream.get_nextsound argument must contain {}, 
                   {} were given'''.format(key, part)
             raise TypeError(str_to_error_message(msg))
     return True
Exemple #2
0
 def wrapper(self, time):
     if time > self.get_duration():
         err = f'''You ask about {time} but
                   {self.short_str()}.get_duration() is
                   {self.get_duration()}'''
         raise OSError(str_to_error_message(err))
     return func(self, time)
Exemple #3
0
 def short_str(self):
     if self.need_copy:
         rt = "("
         rt += " + ".join([v.short_str() for v in self.videos_list])
         rt += ")"
         return rt
     rt = f'''{__class__.__name__}([v.short_str() for v in
              self.videos_list], need_copy=False)'''
     return str_to_error_message(rt)
Exemple #4
0
 def get_duration(self):       #  Use 'Ani5kkF30f' for search
     """
     Function that return duration of video.
     You need overload it if you use SumOfVideo for your type
     You no need overload it if you use SumOfVideo for
     PartOfVideo of your type. (PartOfVideo have get_duration method)"""
     msg = '''You call {}.get_duration() (may be in SumOfVideo(v1, v2)
              or v1 + v2) method but not overload it'''
     AttributeError(str_to_error_message(msg.format(self)))
Exemple #5
0
 def get_frame(self, *args, **kwargs): #  Use '0t1SPHSW8B' for search
     """
     Overloaded 'get_frame' method must takes time in arg 
     and return frame in that time.
     """
     msg = '''All classes inherited of {} must overload '{}' method;
              #  Use '0t1SPHSW8B' for search'''
     msg = str_to_error_message(msg.format(__class__, "get_frame"))
     raise Exception(msg)
Exemple #6
0
 def get_duration(self):
     # print("get_duration calling")
     if self.duration == -1:
         msg = ''' .But you don't point out duration in
                      {}.__init__({}, {}). It trror may be raised if int
                      SumOfVideo previos video have small duration and
                      this video didn't have time to download.
                   '''.format(__class__, self, self.video_id)
         raise AttributeError(str_to_error_message(msg))
     return self.duration
Exemple #7
0
 def __call__(self, *args, **kwargs):
     """
     Create SmartAcceleratedVideo(self, Settings(**dict)) where 'dict' is
         if not args:
             dict = kwargs
         if args is (settings_obj):
             dict = settings_obj.to_dict().update(kwargs)        
     """
     if not args:
         settings_dict = kwargs  
     elif len(args) == 1 and isinstance(args[0], Settings):
         settings_dict = args[0].to_dict()
         settings_dict.update(kwargs)
     elif len(args) == 1:
         msg = '''arg in Video(arg, **kwargs) must be <class Settings>
                 type type({}) = {} were given'''.format(arg, type(arg))
         raise TypeError(str_to_error_message(msg))
     else: 
         msg = '''Video(*args, **kwargs) takes 0 or 1 arguments in *args
                  Video(*{}, **{}) were given'''.format(args, kwargs)
         raise TypeError(str_to_error_message(msg))
     return SmartAcceleratedVideo(self, Settings(**settings_dict))
Exemple #8
0
 def long_str(self):
     rt = f'''{__class__.__name__}({self.video},
              {self.start_time}, {self.end_time})'''
     return str_to_error_message(rt)