Code Monkey home page Code Monkey logo

twitterspaces2text's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

twitterspaces2text's Issues

difficulty with downloading live

Hello,

So I've tried jumping into a live twitter space that has already started.
Let's say I would like to grab the transcript from the beginning to capture what I have missed.
So I go ahead and grab the spaces id and insert it.
The script does capture from the start of the stream through the timestamp that the script was initialized.
The script works for both 'recorded by host' and 'non-recorded by host' streams.
It completes the output as desired.
As you would expect, there is an error generated eventually since the spaces has not ended yet as follows:

[start]
C:\path>py twitspace07-10-21.py >> test301a.txt
Traceback (most recent call last):
File "C:\Python\lib\site-packages\requests\models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Python\lib\json_init_.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Python\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Python\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\path\twitspace07-10-21.py", line 4, in
extractor.getCaption("1ZkJzbbELoaJv")
File "C:\Python\lib\site-packages\TwitterSpaces2Text\Extractor.py", line 50, in getCaption
raw_data = self.getCurrentCaption(cursor)
File "C:\Python\lib\site-packages\TwitterSpaces2Text\Extractor.py", line 40, in getCurrentCaption
json={"access_token":self.access_token ,"cursor":cursor,"limit":1000,"since":None,"quick_get":True}).json()
File "C:\Python\lib\site-packages\requests\models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[end]

So, I think, no problem, i'll just delete the initial output text file and rerun the script a few minutes later to capture a longer transcript.

However, the problems start if I try to rerun the same script for the same space id subsequently.
The intent is to replace the already downloaded transcript by extending the transcript timeframe beyond the initially downloaded timeframe.
What happens is that the output will keep ending at the same initial timestamped request point (despite the fact that the script is being initialized with a much later timestamp while the space is still live, or for a recorded stream rerunning after the stream has ended)

  1. I have tried closing the command line window and reopening it.
  2. I have tried clearing the cache with "cleanpy -avf --exclude-envs c:\python"
  3. it seems like the initially downloaded output is cached somewhere but I can't find out where it is so I can flush it.
  4. the issue persists even if the stream is recorded and I wait until after the stream ends before rerunning the script.
  5. I have also tried renaming the py file and renaming the output text file name before rerunning the script. I have tried placing the py file in a different folder.
  6. so the cache seems to be tied directly to the specific spaces id.
  7. my setup - windows 10, Python 3.10.5, pip 22.1.2
  8. the problem persists regardless of the output file - for example i have tried removing the write to file aspect and the screen output also stops at the same initial timestamp download point.

Thanks in advance.

Periscope API

Hi, it seems that this script is using some Periscope APIs.
This surprised me a bit, since Periscope has been deprecated already.
Is there a way to achieve something similar with only the Twitter API?

KeyError: 'metadata' When Attempting

KeyError Traceback (most recent call last)
Cell In [118], line 2
1 # %%
----> 2 extractor.getCaption("1YqGopyVqkvJv")

File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/TwitterSpaces2Text/Extractor.py:44, in Extractor.getCaption(self, spaces_id)
42 self.spaces_id = spaces_id
43 self.setGuestToken()
---> 44 self.setMediaKey()
45 self.setChatToken()
46 self.setAccessToken()

File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/TwitterSpaces2Text/Extractor.py:29, in Extractor.setMediaKey(self)
27 data['variables']["withReplays"] = True
28 data['variables']["withScheduledSpaces"] = True
---> 29 self.media_key = requests.get('https://twitter.com/i/api/graphql/jyQ0_DEMZHeoluCgHJ-U5Q/AudioSpaceById',
30 headers={"x-guest-token":self.guest_token,"Authorization":self.bearer_token,'Content-Type':'application/json'},
31 json=data).json()['data']['audioSpace']['metadata']['media_key']

KeyError: 'metadata'

install error

Hello,

I am getting this error when trying to install on
C:\Python>py --version
Python 3.10.5
/Thanks in advance!

C:\Users\slimjim>pip install TwitterSpaces2Text
Collecting TwitterSpaces2Text
Using cached TwitterSpaces2Text-0.1.tar.gz (2.6 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [12 lines of output]
Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "C:\Users\slimjim\AppData\Local\Temp\pip-install-t7obqjaz\twitterspaces2text_a152f74be907404ea36a7491c5df9dae\setup.py", line 3, in
subprocess.run(["pandoc","--from=markdown","--to=rst","--output=README","README.md"])
File "C:\Python\lib\subprocess.py", line 501, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Python\lib\subprocess.py", line 969, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Python\lib\subprocess.py", line 1438, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

(i was able to install another github also stored in same site-packages directory with success
C:\Users\slimjim>pip install pyautogui
...
Successfully installed PyTweening-1.0.4 mouseinfo-0.1.3 pyautogui-0.9.53 pygetwindow-0.0.9 pymsgbox-1.0.9 pyperclip-1.8.2 pyrect-0.2.0 pyscreeze-0.1.28)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.