philbot9 / youtube-info

Fetch meta information about YouTube videos
ISC License
43 stars 20 forks source link

fix parser #8

Closed aulianov closed 5 years ago

aulianov commented 5 years ago

get title from h1 title container if exist and decodeEntities set to false

philbot9 commented 5 years ago

Hey, thanks for these. I'm holding this back for a little bit as I am working on a new major version. Once done, I'll post here so you can rebase your code.

philbot9 commented 5 years ago

@aulianov Sorry for the delay. The video parser is now in lib/video. I've changed the API:

const youtubeInfo = require('youtube-info')

youtubeInfo.video('abc123').then(...)

I have one concern regarding this PR. The lang prop on <html> will always correspond to what was requested in the "Accept-Language" header. So it will be set to the requested language even if the title and description are not available in that language. I think that's incorrect, because the user might think they have translated data when they do not.

I haven't yet found another way to determine whether the title and description are translated, other than going through the API. think we should remove the field language in the result until we can find a way to do this.

aulianov commented 5 years ago

Thank you. I do not see problems with missing languages. If I send a request for Rb0UmrCXxVA {language: 'jp'}, then the answer comes to me with the default language parameter, not 'jp'. It works fine.

philbot9 commented 5 years ago

@aulianov That's true, but only because 'jp' is not a valid locale. Japanese is 'ja'.

If you try {language: 'de'} for example you'll see <html lang="de">, yet the title and description of the video are still in English.

aulianov commented 5 years ago

Ahh, I see But for my case, it works great. I think it makes no sense to request a language that does not exist.