question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 28 (char 27)

See original GitHub issue

Hello! Inexperienced Github & Python user here! I’m running into an issue pulling in a specific video from YouTube. I’m running Pytube 9.7.0 on PyCharm Community Edition 2020.1.4. The code is as follows:

from pytube import YouTube

yt = YouTube("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
print(yt.title)

Expect output should be:

Rick Astley - Never Gonna Give You Up (Video)

But instead, I’m getting:

Traceback (most recent call last):
  File "C:/Users/user/AppData/Roaming/JetBrains/PyCharmCE2020.1/scratches/scratch.py", line 3, in <module>
    yt = YouTube("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
  File "C:\Users\user\Projects\PycharmProjects\venv\lib\site-packages\pytube\__main__.py", line 103, in __init__
    self.descramble()
  File "C:\Users\user\Projects\PycharmProjects\venv\lib\site-packages\pytube\__main__.py", line 123, in descramble
    self.player_config_args = get_ytplayer_config(self.watch_html)[
  File "C:\Users\user\Projects\PycharmProjects\venv\lib\site-packages\pytube\extract.py", line 203, in get_ytplayer_config
    return json.loads(yt_player_config)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\json\__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\json\decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 28 (char 27)

Process finished with exit code 1

The code appears to work for other videos as intended:

from pytube import YouTube

yt = YouTube("https://www.youtube.com/watch?v=2lAe1cqCOXo&t")
print(yt.title)
YouTube Rewind 2019: For the Record | #YouTubeRewind

Process finished with exit code 0

I don’t think I have the programming experience to decipher the error traceback. Is anyone else able to replicate this issue?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16

github_iconTop GitHub Comments

5reactions
tfdahlincommented, Dec 9, 2020

hi @chandeepadissanayake this is because that branch has been merged into the main repo. The command you want to use now is pip install git+https://github.com/nficano/pytube. That previous command was to install an experimental branch

4reactions
snowblinkrxcommented, Dec 9, 2020

updated, and yes, that worked. thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python & JSON: ValueError: Unterminated string starting at
The code works for every other file but this. So I'm sure it has something to do with one of the fields that...
Read more >
json.decoder.JSONDecodeError: Unterminated string starting ...
My application receives a request with a json body that contains a ... JSONDecodeError: Unterminated string starting at: line 1 column 18 ...
Read more >
Unterminated string starting at: line 1 column 127395 (char ...
Uploading the test add-on (attached), I get the following traceback on validation: "Traceback (most recent call last): File ...
Read more >
Incorrect position reported in JSONDecodeError when loading ...
When loading an invalid json that ends in an unterminated string that ... JSONDecodeError: Unterminated string starting at: line 1 column 1 ......
Read more >
Source code for json.decoder - nbodykit - Read the Docs
"""Implementation of JSONDecoder """ import re from json import scanner try: ... if chunk is None: raise JSONDecodeError("Unterminated string starting at", ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found