]> git.0d.be Git - botaradio.git/commitdiff
get youtube audio duration in seconds
authorFrédéric Péters <fpeters@0d.be>
Mon, 23 Mar 2020 05:26:33 +0000 (06:26 +0100)
committerFrédéric Péters <fpeters@0d.be>
Mon, 23 Mar 2020 05:26:33 +0000 (06:26 +0100)
media/url.py

index f5f416314bd56aa589aa3b0a233646c279faf4d5..1842ab5a084dfa50de5e445910b1f05bbafa1fd4 100644 (file)
@@ -93,7 +93,7 @@ class URLItem(BaseItem):
         if not info:
             return False
 
-        if self.duration > var.config.getint('bot', 'max_track_duration') != 0:
+        if self.duration > (var.config.getint('bot', 'max_track_duration') * 60) != 0:
             # Check the length, useful in case of playlist, it wasn't checked before)
             log.info(
                 "url: " + self.url + " has a duration of " + str(self.duration) + " min -- too long")
@@ -124,7 +124,8 @@ class URLItem(BaseItem):
             for i in range(attempts):
                 try:
                     info = ydl.extract_info(self.url, download=False)
-                    self.duration = info['duration'] / 60
+                    print('info:', info)
+                    self.duration = info['duration']
                     self.title = info['title']
                     succeed = True
                     return True