livestream_saver icon indicating copy to clipboard operation
livestream_saver copied to clipboard

Unable to start livestream_saver on Ubuntu

Open hbbernardo opened this issue 2 years ago • 9 comments

I'm getting this error (below) when i try to initialize it.

I followed the install instructions.

python3.8 livestream_saver.py monitor --help Traceback (most recent call last):

File "livestream_saver.py", line 12, in from livestream_saver import extract, util File "/home/hobbes/livestream_saver.py", line 12, in from livestream_saver import extract, util ImportError: cannot import name 'extract' from partially initialized module 'livestream_saver' (most likely due to a circular import) (/home//hobbes/livestream_saver.py)

What I did do wrong?

Please, let me know

hbbernardo avatar Nov 17 '22 15:11 hbbernardo

I suspect that you have a /home/hobbes/livestream_saver/ directory alongside your /home/hobbes/livestream_saver.py which confuses python. If that is the case, delete or move that directory (better yet, move everything inside that directory instead).

glubsy avatar Nov 17 '22 20:11 glubsy

I moved everything into a new directory called livestream. To no avail.

ls livestream/ livestream_saver.py requirements.txt

~/livestream$ python3.8 livestream_saver.py monitor --help Traceback (most recent call last): File "livestream_saver.py", line 12, in from livestream_saver import extract, util File "/home/hobbes/livestream/livestream_saver.py", line 12, in from livestream_saver import extract, util ImportError: cannot import name 'extract' from partially initialized module 'livestream_saver' (most likely due to a circular import) (/home/hobbes/livestream/livestream_saver.py)

Doing the requirements part I noticed that this error happened:

Traceback (most recent call last): File "/tmp/pip-build-9vmxvr2s/Pillow/setup.py", line 995, in setup( File "/usr/lib/python3/dist-packages/setuptools/init.py", line 129, in setup return distutils.core.setup(**attrs) File "/usr/lib/python3.8/distutils/core.py", line 148, in setup dist.run_commands() File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands self.run_command(cmd) File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/usr/lib/python3/dist-packages/setuptools/command/install.py", line 61, in run return orig.install.run(self) File "/usr/lib/python3.8/distutils/command/install.py", line 589, in run self.run_command('build') File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/usr/lib/python3.8/distutils/command/build.py", line 135, in run self.run_command(cmd_name) File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/usr/lib/python3/dist-packages/setuptools/command/build_ext.py", lin e 78, in run _build_ext.run(self) File "/usr/lib/python3.8/distutils/command/build_ext.py", line 340, in run self.build_extensions() File "/tmp/pip-build-9vmxvr2s/Pillow/setup.py", line 810, in build_extensi ons raise RequiredDependencyException(f) main.RequiredDependencyException: jpeg

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-9vmxvr2s/Pillow/setup.py", line 1012, in <module>
    raise RequiredDependencyException(msg)
__main__.RequiredDependencyException:

The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.

Please see the install instructions at:
   https://pillow.readthedocs.io/en/latest/installation.html



----------------------------------------

Command "/usr/bin/python3.8 -u -c "import setuptools, tokenize;file='/tmp/pi p-build-9vmxvr2s/Pillow/setup.py';f=getattr(tokenize, 'open', open)(file);co de=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec') )" install --record /tmp/pip-d3g7d0hv-record/install-record.txt --single-version -externally-managed --compile --user --prefix=" failed with error code 1 in /tmp /pip-build-9vmxvr2s/Pillow/

Any ideas?

hbbernardo avatar Nov 17 '22 21:11 hbbernardo

There is something wrong with your setup.

You might want to look into setting up a virtual environment as is described in the Readme, then install dependencies in that virtual environment with pip.

Can you confirm you have the exact same directory structure as in this here repository? Beyond that I don't know why this is occurring.

glubsy avatar Nov 17 '22 21:11 glubsy

I did a clean install of Raspberry Pi OS on a new SDCard.

The only thing I installed was python-pip. Nothing else.

hbs@raspberrypi:~/livestream $ python3.9 -m pip install -r requirements.txt Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Requirement already satisfied: pytube==10.9.2 in /home/hbs/.local/lib/python3.9/site-packages (from -r requirements.txt (line 1)) (10.9.2) Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (from -r requirements.txt (line 2)) (8.1.2)

When I tried to run, the same thing happened.

hbs@raspberrypi:~/livestream $ python3.9 livestream_saver.py download --cookie cookie.txt https://www.youtube.com/watch?v=86YLFOog4GM Traceback (most recent call last): File "/home/hbs/livestream/livestream_saver.py", line 12, in from livestream_saver import extract, util File "/home/hbs/livestream/livestream_saver.py", line 12, in from livestream_saver import extract, util ImportError: cannot import name 'extract' from partially initialized module 'livestream_saver' (most likely due to a circular import) (/home/hbs/livestream/livestream_saver.py)

This is what is inside my home user:

image

hbbernardo avatar Nov 17 '22 22:11 hbbernardo

I managed to reproduce this by not having a livestream_saver directory alongside livestream_saver.py. You need to have the same directory structure as is in the repository and I suspect you are missing files for some reason. How have you cloned the repository? You need to have all files:

~/livestream/livestream_saver.py
~/livestream/...
~/livestream/livestream_saver/
~/livestream/livestream_saver/__init__.py
~/livestream/livestream_saver/...

glubsy avatar Nov 17 '22 23:11 glubsy

I was able to fix it.

It started downloading a live stream but at a certain point, it stopped with an error. This was on a Ubuntu machine. The first one i mentioned above.

python3.8 livestream_saver.py download --log-level CRITICAL --cookie ~hbs/cookie.txt https://www.youtube.com/watch?v=V9rlTQCg0Ow 2022-11-18 01:30:09,325 - CRITICAL - livestream_saver.request - We are not logged in. Check the validity of your cookies!

2022-11-18 01:11:16,648 - CRITICAL - download.V9rlTQCg0Ow - Some kind of error occured during download? Stream format mismatch after update of base URL.

What it is missing?

hbbernardo avatar Nov 18 '22 00:11 hbbernardo

The path to your cookie.txt file is wrong, it should be ~/hbs/cookies.txt.

The error you got is a known issue. You can circumvent the problem by using the --ignore-quality-change argument. It's not documented in the Readme yet, because it might not work reliably. There is still some work to be done.

glubsy avatar Nov 18 '22 20:11 glubsy

For the last week up to today, I've been using this option trying to salvage my live streams on YouTube to no avail

All of them ended with an error right in the middle saying that a mismatch occurred. Nothing could be saved.

I tried to concatenate another live stream that I captured that I did only for testing purposes which also ended in a mismatch. I ended up canceling the action because even on my remote server it took more than a day to end.

I must apologize because I don't have any logs to show as of now. I deleted the whole thing to start over.

But tomorrow and on I will be able to provide some. I've left livestream_stream saver monitoring a YouTube channel. The same one and the only one that I am trying to capture since the very beginning.

I've used this; python3 livestream_saver.py monitor --ignore-quality-change -d --scan-delay 30 URL

I did a git pull and everything seems to be up-to-date.

hbbernardo avatar Nov 29 '22 16:11 hbbernardo

Yeah, I had that error come up randomly but it seems to occur more with certain streamers than others. Not sure why exactly but I'll try to handle it better in future versions.

Another thing you might want to do is automatically start a side-car application to record your live streams, like yt-dlp for example. You can use the hooks described in "hooks on event" section in the Readme.

glubsy avatar Nov 29 '22 16:11 glubsy