{"record":{"id":"c66ebe2485b173c1","repo":"soimort/you-get","slug":"s-is-paid-item","errorCode":null,"errorMessage":"%s is paid item","messagePattern":"(.+?) is paid item","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"src/you_get/extractors/ximalaya.py","lineNumber":25,"sourceCode":"import json\nimport re\n\nstream_types = [\n        {'itag': '1', 'container': 'm4a', 'bitrate': 'default'},\n        {'itag': '2', 'container': 'm4a', 'bitrate': '32'},\n        {'itag': '3', 'container': 'm4a', 'bitrate': '64'}\n        ]\n\ndef ximalaya_download_by_id(id, title = None, output_dir = '.', info_only = False, stream_id = None):\n    BASE_URL = 'http://www.ximalaya.com/tracks/'\n    json_url = BASE_URL + id + '.json'\n    json_data = json.loads(get_content(json_url, headers=fake_headers))\n    if 'res' in json_data:\n        if json_data['res'] == False:\n            raise ValueError('Server reported id %s is invalid' % id)\n    if 'is_paid' in json_data and json_data['is_paid']:\n        if 'is_free' in json_data and not json_data['is_free']:\n            raise ValueError('%s is paid item' % id)\n    if (not title) and 'title' in json_data:\n        title = json_data['title']\n#no size data in the json. should it be calculated?\n    size = 0\n    url = json_data['play_path_64']\n    if stream_id:\n        if stream_id == '1':\n            url = json_data['play_path_32']\n        elif stream_id == '0':\n            url = json_data['play_path']\n    logging.debug('ximalaya_download_by_id: %s' % url)\n    ext = 'm4a' \n    urls = [url]\n    print('Site:        %s' % site_info)\n    print('title:       %s' % title)\n    if info_only:\n        if stream_id:\n            print_stream_info(stream_id)","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/soimort/you-get/blob/049548f3f3f35e67ba8d3181c71fdc71d11cf260/src/you_get/extractors/ximalaya.py#L7-L43","documentation":"The Ximalaya tracks API returned is_paid: true with is_free falsy, meaning the audio requires purchase; without a paid session there is no playable stream, so the extractor raises ValueError('%s is paid item') instead of attempting a download that would fail opaquely.","triggerScenarios":"Downloading a /sound/<id> for a VIP/paid album track: json_data['is_paid'] is truthy and json_data['is_free'] is false at src/you_get/extractors/ximalaya.py:25-27.","commonSituations":"Album pages mixing free previews with paid chapters; users assuming playlist download covers everything; trial/first episodes being free while the rest are paid.","solutions":["Verify the track's paid status on the Ximalaya album page in a browser","Download only the free episodes (skip paid ones in a loop, catching ValueError as ximalaya_download_page does)","Purchase the content / use an entitled account if the extractor supports cookies (add auth headers to the get_content call)","Check whether a free lower-quality version exists under a different track id"],"exampleFix":"# before\nfor id in ids:\n    ximalaya_download_by_id(id, output_dir=output_dir, info_only=info_only)\n\n# after\nfor id in ids:\n    try:\n        ximalaya_download_by_id(id, output_dir=output_dir, info_only=info_only)\n    except ValueError:\n        print('skipping %s (paid or invalid)' % id)","handlingStrategy":"try-catch","validationCode":"import json\n\ndef ximalaya_track_free(track_id, fetch):\n    d = json.loads(fetch('http://www.ximalaya.com/tracks/%s.json' % track_id))\n    return not (d.get('is_paid') and not d.get('is_free', False))","typeGuard":null,"tryCatchPattern":"try:\n    ximalaya_download(url, ...)\nexcept ValueError as e:\n    if 'paid item' in str(e):\n        print('paid track; skip or purchase')\n    else:\n        raise","preventionTips":["Check is_paid/is_free on the tracks JSON before queueing downloads","Expect paid chapters inside free albums — design batch jobs to skip, not abort","Message says 'perhaps paid item?' in playlist mode; log those ids for manual review"],"tags":["ximalaya","paid-content","paywall"],"backgroundTag":null,"analyzedSha":"049548f3f3f35e67ba8d3181c71fdc71d11cf260","analyzedAt":"2026-08-15T03:58:15.069Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}