Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local variable 'twspace_dl' referenced before assignment #32

Closed
JC-Chung opened this issue Jan 15, 2022 · 8 comments
Closed

local variable 'twspace_dl' referenced before assignment #32

JC-Chung opened this issue Jan 15, 2022 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@JC-Chung
Copy link
Contributor

Describe the bug
https://github.com/Ryu1845/twspace-dl/blob/1ca12aa975c40c5d9020709e22332b041b2f13ef/twspace_dl/__main__.py#L173-L176

To Reproduce
twspace_dl -f https://prod-fastly-ap-northeast-1.video.pscp.tv/Transcoding/v1/hls/YRSsw6_P5xUZHMualK5-ihvePR6o4QmoZVOBGicKvmkL_KB9IQYtxVqm3P_vpZ2HnFkoRfar4_uJOjqC8OCo5A/non_transcode/ap-northeast-1/periscope-replay-direct-prod-ap-northeast-1-public/audio-space/master_playlist.m3u8

Expected behavior
use the master url for the processes(useful for ended spaces)

Output
If applicable, add the output of the command to help explain your problem.

Traceback (most recent call last):
  File "c:\users\test01\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\test01\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\test01\AppData\Local\Programs\Python\Python39\Scripts\twspace_dl.exe\__main__.py", line 7, in <module>
  File "c:\users\test01\appdata\local\programs\python\python39\lib\site-packages\twspace_dl\__main__.py", line 116, in main
    args.func(args)
  File "c:\users\test01\appdata\local\programs\python\python39\lib\site-packages\twspace_dl\__main__.py", line 176, in twspace
    twspace_dl.master_url = args.from_master_url
UnboundLocalError: local variable 'twspace_dl' referenced before assignment

Desktop (please complete the following information):

  • OS: Windows
  • Version 2022.1.13.0
  • Installation method pip

Additional context
Same problem in twspace_dl -d DYN_URL

@JC-Chung JC-Chung added the bug Something isn't working label Jan 15, 2022
@Ryu1845
Copy link
Collaborator

Ryu1845 commented Jan 15, 2022

Fixed in latest release

@Ryu1845 Ryu1845 closed this as completed Jan 15, 2022
@JC-Chung
Copy link
Contributor Author

JC-Chung commented Jan 15, 2022

twspace_dl -s -i https://twitter.com/i/spaces/1LyxBokRPDaKN -u
display the master url

twspace_dl -f https://prod-fastly-ap-northeast-1.video.pscp.tv/Transcoding/v1/hls/yenulOtsWltjshnjilUs9lzZr_kOg0JiHrS1BEouSLNxgxVa6K2tIFJ65xUghGc0BKMho36dEzpIT9n6j57OeQ/non_transcode/ap-northeast-1/periscope-replay-direct-prod-ap-northeast-1-public/audio-space/master_playlist.m3u8 -o "[la_po].mp4"
use the master url for the processes(useful for ended spaces)

ERROR:root:{'errors': [{'message': 'BadRequest: invalid broadcast_ids=[no_id]', 'locations': [{'line': 8, 'column': 3}], 'path': ['audioSpace', 'metadata'], 'extensions': {'name': 'BadRequestError', 'source': 'Client', 'code': 214, 'kind': 'Validation', 'tracing': {'trace_id': '38d648479d2456f1'}}, 'code': 214, 'kind': 'Validation', 'name': 'BadRequestError', 'source': 'Client', 'tracing': {'trace_id': '38d648479d2456f1'}}, {'message': 'BadRequest: invalid broadcast_ids=[no_id]', 'locations': [{'line': 28, 'column': 3}], 'path': ['audioSpace', 'sharings'], 'extensions': {'name': 'BadRequestError', 'source': 'Client', 'code': 214, 'kind': 'Validation', 'tracing': {'trace_id': '38d648479d2456f1'}}, 'code': 214, 'kind': 'Validation', 'name': 'BadRequestError', 'source': 'Client', 'tracing': {'trace_id': '38d648479d2456f1'}}], 'data': {'audioSpace': {}}}
Traceback (most recent call last):
  File "c:\users\test01\appdata\local\programs\python\python39\lib\site-packages\twspace_dl\twspace_dl.py", line 193, in metadata
    media_key = metadata["data"]["audioSpace"]["metadata"]["media_key"]
KeyError: 'metadata'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\users\test01\appdata\local\programs\python\python39\lib\site-packages\twspace_dl\__main__.py", line 189, in twspace
    twspace_dl.download()
  File "c:\users\test01\appdata\local\programs\python\python39\lib\site-packages\twspace_dl\twspace_dl.py", line 280, in download
    metadata = self.metadata
  File "c:\users\test01\appdata\local\programs\python\python39\lib\functools.py", line 969, in __get__
    val = self.func(instance)
  File "c:\users\test01\appdata\local\programs\python\python39\lib\site-packages\twspace_dl\twspace_dl.py", line 197, in metadata
    raise RuntimeError(metadata) from error
RuntimeError: {'errors': [{'message': 'BadRequest: invalid broadcast_ids=[no_id]', 'locations': [{'line': 8, 'column': 3}], 'path': ['audioSpace', 'metadata'], 'extensions': {'name': 'BadRequestError', 'source': 'Client', 'code': 214, 'kind': 'Validation', 'tracing': {'trace_id': '38d648479d2456f1'}}, 'code': 214, 'kind': 'Validation', 'name': 'BadRequestError', 'source': 'Client', 'tracing': {'trace_id': '38d648479d2456f1'}}, {'message': 'BadRequest: invalid broadcast_ids=[no_id]', 'locations': [{'line': 28, 'column': 3}], 'path': ['audioSpace', 'sharings'], 'extensions': {'name': 'BadRequestError', 'source': 'Client', 'code': 214, 'kind': 'Validation', 'tracing': {'trace_id': '38d648479d2456f1'}}, 'code': 214, 'kind': 'Validation', 'name': 'BadRequestError', 'source': 'Client', 'tracing': {'trace_id': '38d648479d2456f1'}}], 'data': {'audioSpace': {}}}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\test01\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\test01\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\test01\AppData\Local\Programs\Python\Python39\Scripts\twspace_dl.exe\__main__.py", line 7, in <module>
  File "c:\users\test01\appdata\local\programs\python\python39\lib\site-packages\twspace_dl\__main__.py", line 116, in main
    args.func(args)
  File "c:\users\test01\appdata\local\programs\python\python39\lib\site-packages\twspace_dl\__main__.py", line 193, in twspace
    if not args.keep_files and os.path.exists(twspace_dl._tmpdir):
AttributeError: 'TwspaceDL' object has no attribute '_tmpdir'

Desktop (please complete the following information):

  • OS: Windows
  • Version 2022.1.15.0
  • Installation method pip

@Ryu1845
Copy link
Collaborator

Ryu1845 commented Jan 15, 2022

I know what the problem is and I'm going to fix it. But you can just add -i <space url> to fix it. The error won't happen and you'll get the metadata embedded too

@JC-Chung
Copy link
Contributor Author

I know what the problem is and I'm going to fix it. But you can just add -i <space url> to fix it. The error won't happen and you'll get the metadata embedded too

But if the space is unarchive, then can't use -i <space url> to download it.
((Although it sounds normal.

@Ryu1845
Copy link
Collaborator

Ryu1845 commented Jan 17, 2022

You can't use it to get the master url but you can use it to get metadata. (like the user making the space etc.)

@Ryu1845
Copy link
Collaborator

Ryu1845 commented Jan 17, 2022

You can use
twspace_dl -f <master url> -i <space url>

@JC-Chung
Copy link
Contributor Author

If space is online and unarchive, does I can use twspace_dl -f <master url> to download from start? Even just use twspace_dl -i <space url>? (like #31 ?)
By the way, is normal that twspace_dl -i <space url> sometimes will missing few frags when space online?
Cause it miss more than I use youtube-dl <dyn url> to download, even my computer didn't do other work.
Thank you for your help.

@Ryu1845
Copy link
Collaborator

Ryu1845 commented Jan 17, 2022

If space is online [...] can I use twspace_dl -f <master url> to download from start?

No

Even just use twspace_dl -i <space url>? (like #31 ?)

I don't understand

By the way, is normal that twspace_dl -i <space url> sometimes will missing few frags when space online?

I knew it could happen but I thought it would only be one max.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants