Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils.js_to_json is broken: mishandles commented lines #23785

Open
israel-lugo opened this issue Jan 19, 2020 · 1 comment · May be fixed by #23877
Open

utils.js_to_json is broken: mishandles commented lines #23785

israel-lugo opened this issue Jan 19, 2020 · 1 comment · May be fixed by #23877

Comments

@israel-lugo
Copy link

@israel-lugo israel-lugo commented Jan 19, 2020

Tested with youtube-dl 2020.01.15 and 2020.01.01.

>>> from youtube_dl import utils
>>> input = """{
...   foo: "value",
...   // bar: { nested:'x' },
...   bar: { nested:'x' },
...   chaff: "something"
... }"""
>>> print(utils.js_to_json(input))
{
  "foo": "value"
  
  "bar": { "nested":"x" },
  "chaff": "something"
}

Note that the "foo": "value" line has lost its trailing ',' with the transformation (it was there in the input). This is invalid JSON and is causing issue #23707.

@israel-lugo
Copy link
Author

@israel-lugo israel-lugo commented Jan 19, 2020

Real life example, input:

{
          id: "player_prog",
          fileKey: "/nas2.share/pt/h264/512x384/p6265/p6265_1_201912152233180805.mp4",
          file : "https://ondemand-streaming.rtp.pt/nas2.share/pt/h264/512x384/p6265/index.m3u8?tlm=hls&streams=p6265_1_201912152233180805.mp4.m3u8:1024",
                                  seekBarThumbnailsLoc: '//cdn-images.rtp.pt/multimedia/screenshots/p6265/preview/p6265_1_201912152233180805_preview.vtt',
                      adsType: 'dfp',
          subadUnit: 'Play',
          streamType:"ondemand",
          googleCast: true,
          //extraSettings: { googleCastReceiverAppId:'1A6F2224', skin:'s3',  skinAccentColor: '0073FF'},
          extraSettings: { googleCastReceiverAppId:'1A6F2224'},
          mediaType: "video",
          poster: "https://cdn-images.rtp.pt/EPG/imagens/37684_55429_70561.jpg?v=3&w=1170"
        }

Is getting transformed to:

{
          "id": "player_prog",
          "fileKey": "/nas2.share/pt/h264/512x384/p6265/p6265_1_201912152233180805.mp4",
          "file" : "https://ondemand-streaming.rtp.pt/nas2.share/pt/h264/512x384/p6265/index.m3u8?tlm=hls&streams=p6265_1_201912152233180805.mp4.m3u8:1024",
                                  "seekBarThumbnailsLoc": "//cdn-images.rtp.pt/multimedia/screenshots/p6265/preview/p6265_1_201912152233180805_preview.vtt",
                      "adsType": "dfp",
          "subadUnit": "Play",
          "streamType":"ondemand",
          "googleCast": true
          
          "extraSettings": { "googleCastReceiverAppId":"1A6F2224"},
          "mediaType": "video",
          "poster": "https://cdn-images.rtp.pt/EPG/imagens/37684_55429_70561.jpg?v=3&w=1170"
        }

Note the missing trailing , after "googleCast": true".

@TinyToweringTree TinyToweringTree linked a pull request that will close this issue Jan 28, 2020
5 of 9 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant
You can’t perform that action at this time.