我正在尝试通过脚本在youtube上上传视频,但是执行脚本时出现此错误。我用另一个脚本以不同的方式执行相同操作时测试了json文件,我尝试了所有这是最后一次机会,否则我将放弃该脚本。 如果您需要更多详细信息,请告诉我,谢谢您的努力!
Extra data: line 1 column 427 (char 426)
Traceback (most recent call last):
File "publisher/botTest.py", line 54, in <module>
youtubeService.uploadVideoToYouTube(config)
File "/root/publisher/core/services/youtube.py", line 202, in uploadVideoToYouTube
youtube = getAuthenticatedService(CREDENTIALS_FILE)
File "/root/publisher/core/services/youtube.py", line 69, in getAuthenticatedService
flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES,redirect_uri='urn:ietf:wg:oauth:2.0:oob')
File "/usr/local/lib/python3.6/dist-packages/google_auth_oauthlib/flow.py",
line 172, in from_client_secrets_file
client_config = json.load(json_file)
File "/usr/lib/python3.6/json/__init__.py", line 299, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.6/json/decoder.py", line 342, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 427 (char 426)
第202行来自youtube.py:
def uploadVideoToYouTube(config):
CREDENTIALS_FILE = constants.SECRETS_ROOT_LOCATION + config['channel'][1] + '/' +
constants.YOUTUBE_CHANNEL_CREDENTIALS_FILE_NAME
if os.path.isfile(CREDENTIALS_FILE):
youtube = getAuthenticatedServiceFromStorage(CREDENTIALS_FILE)
print(os.path.isfile(CREDENTIALS_FILE))
print(CREDENTIALS_FILE) else:
os.makedirs(constants.SECRETS_ROOT_LOCATION + config['channel'][1])
youtube = getAuthenticatedService(CREDENTIALS_FILE)
youtube.py中的第69行:
# Authorize the request and store authorization credentials. Used to
# generate first auth token. Only needs to happen once.
def getAuthenticatedService(CREDENTIALS_FILE):
flow =InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES,
redirect_uri='urn:ietf:wg:oauth:2.0:oob')
auth_url, _ = flow.authorization_url(prompt='consent')
print('Please go to this URL: {}'.format(auth_url))
code = input('Enter the authorization code: ')
credentials = flow.fetch_token(code=code)
saveCredentials(CREDENTIALS_FILE, credentials)
return build(API_SERVICE_NAME, API_VERSION, credentials = flow.credentials)