plugorgau / bbb-render

Scripts to convert a BigBlueButton recording into a single video file
MIT License
65 stars 25 forks source link

error if deskshare.webm is missing somehow #2

Open P-D- opened 3 years ago

P-D- commented 3 years ago

I handled this one my self, adding a try:catch block (thanks stackoverflow https://stackoverflow.com/questions/16778435/python-check-if-website-exists)

-            resp = urllib.request.urlopen(req)
-            content_length = resp.headers['Content-Length']
-            if content_length is not None: content_length = int(content_length)
-            while True:
-                with resp:
-                    n = resp.readinto(buf)
-                    while n > 0:
-                        fp.write(buf[:n])
-                        n = resp.readinto(buf)
-                current = fp.seek(0, os.SEEK_CUR)
-                if content_length is None or current >= content_length:
-                    break
-                print("continuing...")
-                req = urllib.request.Request(url)
-                req.add_header('User-Agent', 'bbb-video-downloader/1.0')
-                req.add_header('Range', f'bytes={current}-')
+            try:
+                resp = urllib.request.urlopen(req)
+            except urllib.error.HTTPError as e:
+                # Return code error (e.g. 404, 501, ...)
+                # ...
+                print('HTTPError: {}'.format(e.code))
+            except urllib.error.URLError as e:
+                # Not an HTTP-specific error (e.g. connection refused)
+                # ...
+                print('URLError: {}'.format(e.reason))
+            else:
+                content_length = resp.headers['Content-Length']
+                if content_length is not None: content_length = int(content_length)
+                while True:
+                    with resp:
+                        n = resp.readinto(buf)
+                        while n > 0:
+                            fp.write(buf[:n])
+                            n = resp.readinto(buf)
+                    current = fp.seek(0, os.SEEK_CUR)
+                    if content_length is None or current >= content_length:
+                        break
+                    print("continuing...")
+                    req = urllib.request.Request(url)
+                    req.add_header('User-Agent', 'bbb-video-downloader/1.0')
+                    req.add_header('Range', f'bytes={current}-')
+                    resp = urllib.request.urlopen(req)
smimram commented 3 years ago

FWIW, I just ran into this one too, it would be nice if some patch could be merged!

Zorlin commented 3 years ago

LGTM but someone else should approve.

On Thu, 4 Feb 2021, 01:47 Samuel Mimram, notifications@github.com wrote:

FWIW, I just ran into this one too, it would be nice if some patch could be merged!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/plugorgau/bbb-render/issues/2#issuecomment-772696665, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKONLD77GU3IWUUW7FXAZDS5GDZ5ANCNFSM4TTEREGA .