soimort/you-get · error · ValueError

Server reported id %s is invalid

Error message

Server reported id %s is invalid

What it means

ximalaya_download_by_id fetches http://www.ximalaya.com/tracks/<id>.json; when the payload contains res == False the server is explicitly reporting the track id is invalid (deleted, never existed, or hidden), so the extractor raises ValueError('Server reported id %s is invalid') before reading play paths.

Source

Thrown at src/you_get/extractors/ximalaya.py:22

from ..common import *

import json
import re

stream_types = [
        {'itag': '1', 'container': 'm4a', 'bitrate': 'default'},
        {'itag': '2', 'container': 'm4a', 'bitrate': '32'},
        {'itag': '3', 'container': 'm4a', 'bitrate': '64'}
        ]

def ximalaya_download_by_id(id, title = None, output_dir = '.', info_only = False, stream_id = None):
    BASE_URL = 'http://www.ximalaya.com/tracks/'
    json_url = BASE_URL + id + '.json'
    json_data = json.loads(get_content(json_url, headers=fake_headers))
    if 'res' in json_data:
        if json_data['res'] == False:
            raise ValueError('Server reported id %s is invalid' % id)
    if 'is_paid' in json_data and json_data['is_paid']:
        if 'is_free' in json_data and not json_data['is_free']:
            raise ValueError('%s is paid item' % id)
    if (not title) and 'title' in json_data:
        title = json_data['title']
#no size data in the json. should it be calculated?
    size = 0
    url = json_data['play_path_64']
    if stream_id:
        if stream_id == '1':
            url = json_data['play_path_32']
        elif stream_id == '0':
            url = json_data['play_path']
    logging.debug('ximalaya_download_by_id: %s' % url)
    ext = 'm4a' 
    urls = [url]
    print('Site:        %s' % site_info)
    print('title:       %s' % title)

View on GitHub (pinned to 049548f3f3)

Solutions

  1. Open http://www.ximalaya.com/tracks/<id>.json in a browser and confirm res:false — verify the track is gone
  2. Find the track's album page and check whether the entry is deleted or paid
  3. If the id came from a playlist scrape, treat it as expected noise: catch ValueError and skip, as ximalaya_download_page already does
  4. Double-check the id for typos when constructing the URL manually

Example fix

# before
try:
    ximalaya_download_by_id(id, ...)
except ValueError:
    print('something wrong with %s, perhaps paid item?' % id)

# after (distinguish invalid vs paid)
try:
    ximalaya_download_by_id(id, ...)
except ValueError as e:
    if 'invalid' in str(e):
        print('track %s was removed, skipping' % id)
    else:
        print('track %s is paid or unavailable, skipping' % id)
Defensive patterns

Strategy: try-catch

Validate before calling

import json

def ximalaya_track_valid(track_id, fetch):
    d = json.loads(fetch('http://www.ximalaya.com/tracks/%s.json' % track_id))
    return d.get('res') is not False

Try / catch

try:
    ximalaya_download(url, ...)
except ValueError as e:
    if 'invalid' in str(e):
        print('track removed; skip')
    else:
        raise

Prevention

When it happens

Trigger: A /sound/<id> URL whose track was removed or is invisible (deleted by uploader, taken down for copyright, or VIP-hidden); also playlist scraping in ximalaya_download_page picking up sound_id attributes of removed tracks (those are caught and printed as 'perhaps paid item?').

Common situations: Stale bookmarked sound links; album pages containing deleted entries; ids transcribed incorrectly; region blocks making tracks appear invalid.

Related errors


AI-assisted analysis of soimort/you-get@049548f3f3 (2026-08-15). Data as JSON: /api/errors/6aa994d42a01e0ea. Report an issue: GitHub.