How to fix Youtube API results title that are returned encodedYoutube Api search results have Quotation Marks errorHow can you encode a string to Base64 in JavaScript?How to dynamically change a web page's title?How do I get a YouTube video thumbnail from the YouTube API?How to do Base64 encoding in node.js?How do I URl encode something in Node.js?How to fix Error: listen EADDRINUSE while using nodejs?How do I return the response from an asynchronous call?How do I convert an existing callback API to promises?Youtube V3 Api not returning the latest resultsYouTube API returns zero results

Why error propagation in CBC mode encryption affect two blocks?

Cooking Scrambled Eggs

How long do you think advanced cybernetic implants would plausibly last?

Why did my folder names end up like this, and how can I fix this using a script?

How much does Commander Data weigh?

What stops you from using fixed income in developing countries?

Does the aliasing loophole apply to signed characters?

Billiard balls collision

To what extent are we obligated to continue to procreate beyond having two kids?

Given current technology, could TV display screens double as video camera sensors?

I don't have the theoretical background in my PhD topic. I can't justify getting the degree

Why can't you reverse the order of the input redirection operator for while loops?

Expanding powers of expressions of the form ax+b

Why is the UK so keen to remove the "backstop" when their leadership seems to think that no border will be needed in Northern Ireland?

Why is getting a PhD considered "financially irresponsible"?

What happened to the HDEV ISS Experiment? Is it over?

Convergence of series of normally distributed random variables

How were medieval castles built in swamps or marshes without draining them?

How to get trace to get a cylinder when I rotate a rectangle?

Can you board the plane when your passport is valid less than 3 months?

Redacting URLs as an email-phishing preventative?

Semantic difference between regular and irregular 'backen'

Make utility using LINQ

Did anybody find out it was Anakin who blew up the command center?



How to fix Youtube API results title that are returned encoded


Youtube Api search results have Quotation Marks errorHow can you encode a string to Base64 in JavaScript?How to dynamically change a web page's title?How do I get a YouTube video thumbnail from the YouTube API?How to do Base64 encoding in node.js?How do I URl encode something in Node.js?How to fix Error: listen EADDRINUSE while using nodejs?How do I return the response from an asynchronous call?How do I convert an existing callback API to promises?Youtube V3 Api not returning the latest resultsYouTube API returns zero results






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I'm using youtube-search 1.1.4 to find videos. The problem is that i get the results titles encoded with & or ' instead of just & and ' and more.



example of one result i got from the example code below (again, added spaces between characters intentionally):
title: "Post Malone - "Wow." (Official Music Video)"



Tried solving this by decodeURI ,decodeURIComponent or unescape which didn't help.
Used a direct call for youtube api and got the same results.
What am i missing?



var youtubeSearch = require("youtube-search")

var opts =
maxResults : 15,
key : 'MY_API_KEY',
part : 'snippet',
type : 'video',
;

youtubeSearch('post malone', opts, function(err, results)
if(err) return console.log(err);

console.dir(results);
);









share|improve this question
























  • If you don't mind using libraries a quick search found me He.js

    – 3limin4t0r
    Mar 27 at 20:08






  • 1





    I've seen this behavior myself for more than two weeks now. My understanding is that this issue is in fact a bug of the API. Maybe you should file a bug report to issuetracker.google.com.

    – stvar
    Mar 27 at 22:24











  • Searched the google issue tracker and found this: issuetracker.google.com/u/1/issues/128673539

    – rami dulman
    Mar 28 at 16:24












  • @ramidulman That is not the same issue. JSON strings must escape the double quote character using a backslash if the string itself contains this character. eg """ is not valid while """ is valid. The linked issue has nothing to do with HTML encoding.

    – 3limin4t0r
    Mar 29 at 18:13











  • @3limin4t0r: sorry, but you are wrong: rami dulman did linked correctly his issue to Google's issue #128673539. See my comment issuetracker.google.com/issues/128673539#comment8.

    – stvar
    Mar 29 at 20:41


















2















I'm using youtube-search 1.1.4 to find videos. The problem is that i get the results titles encoded with & or ' instead of just & and ' and more.



example of one result i got from the example code below (again, added spaces between characters intentionally):
title: "Post Malone - "Wow." (Official Music Video)"



Tried solving this by decodeURI ,decodeURIComponent or unescape which didn't help.
Used a direct call for youtube api and got the same results.
What am i missing?



var youtubeSearch = require("youtube-search")

var opts =
maxResults : 15,
key : 'MY_API_KEY',
part : 'snippet',
type : 'video',
;

youtubeSearch('post malone', opts, function(err, results)
if(err) return console.log(err);

console.dir(results);
);









share|improve this question
























  • If you don't mind using libraries a quick search found me He.js

    – 3limin4t0r
    Mar 27 at 20:08






  • 1





    I've seen this behavior myself for more than two weeks now. My understanding is that this issue is in fact a bug of the API. Maybe you should file a bug report to issuetracker.google.com.

    – stvar
    Mar 27 at 22:24











  • Searched the google issue tracker and found this: issuetracker.google.com/u/1/issues/128673539

    – rami dulman
    Mar 28 at 16:24












  • @ramidulman That is not the same issue. JSON strings must escape the double quote character using a backslash if the string itself contains this character. eg """ is not valid while """ is valid. The linked issue has nothing to do with HTML encoding.

    – 3limin4t0r
    Mar 29 at 18:13











  • @3limin4t0r: sorry, but you are wrong: rami dulman did linked correctly his issue to Google's issue #128673539. See my comment issuetracker.google.com/issues/128673539#comment8.

    – stvar
    Mar 29 at 20:41














2












2








2








I'm using youtube-search 1.1.4 to find videos. The problem is that i get the results titles encoded with & or ' instead of just & and ' and more.



example of one result i got from the example code below (again, added spaces between characters intentionally):
title: "Post Malone - "Wow." (Official Music Video)"



Tried solving this by decodeURI ,decodeURIComponent or unescape which didn't help.
Used a direct call for youtube api and got the same results.
What am i missing?



var youtubeSearch = require("youtube-search")

var opts =
maxResults : 15,
key : 'MY_API_KEY',
part : 'snippet',
type : 'video',
;

youtubeSearch('post malone', opts, function(err, results)
if(err) return console.log(err);

console.dir(results);
);









share|improve this question














I'm using youtube-search 1.1.4 to find videos. The problem is that i get the results titles encoded with & or ' instead of just & and ' and more.



example of one result i got from the example code below (again, added spaces between characters intentionally):
title: "Post Malone - "Wow." (Official Music Video)"



Tried solving this by decodeURI ,decodeURIComponent or unescape which didn't help.
Used a direct call for youtube api and got the same results.
What am i missing?



var youtubeSearch = require("youtube-search")

var opts =
maxResults : 15,
key : 'MY_API_KEY',
part : 'snippet',
type : 'video',
;

youtubeSearch('post malone', opts, function(err, results)
if(err) return console.log(err);

console.dir(results);
);






javascript node.js youtube-data-api






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 20:02









rami dulmanrami dulman

112 bronze badges




112 bronze badges















  • If you don't mind using libraries a quick search found me He.js

    – 3limin4t0r
    Mar 27 at 20:08






  • 1





    I've seen this behavior myself for more than two weeks now. My understanding is that this issue is in fact a bug of the API. Maybe you should file a bug report to issuetracker.google.com.

    – stvar
    Mar 27 at 22:24











  • Searched the google issue tracker and found this: issuetracker.google.com/u/1/issues/128673539

    – rami dulman
    Mar 28 at 16:24












  • @ramidulman That is not the same issue. JSON strings must escape the double quote character using a backslash if the string itself contains this character. eg """ is not valid while """ is valid. The linked issue has nothing to do with HTML encoding.

    – 3limin4t0r
    Mar 29 at 18:13











  • @3limin4t0r: sorry, but you are wrong: rami dulman did linked correctly his issue to Google's issue #128673539. See my comment issuetracker.google.com/issues/128673539#comment8.

    – stvar
    Mar 29 at 20:41


















  • If you don't mind using libraries a quick search found me He.js

    – 3limin4t0r
    Mar 27 at 20:08






  • 1





    I've seen this behavior myself for more than two weeks now. My understanding is that this issue is in fact a bug of the API. Maybe you should file a bug report to issuetracker.google.com.

    – stvar
    Mar 27 at 22:24











  • Searched the google issue tracker and found this: issuetracker.google.com/u/1/issues/128673539

    – rami dulman
    Mar 28 at 16:24












  • @ramidulman That is not the same issue. JSON strings must escape the double quote character using a backslash if the string itself contains this character. eg """ is not valid while """ is valid. The linked issue has nothing to do with HTML encoding.

    – 3limin4t0r
    Mar 29 at 18:13











  • @3limin4t0r: sorry, but you are wrong: rami dulman did linked correctly his issue to Google's issue #128673539. See my comment issuetracker.google.com/issues/128673539#comment8.

    – stvar
    Mar 29 at 20:41

















If you don't mind using libraries a quick search found me He.js

– 3limin4t0r
Mar 27 at 20:08





If you don't mind using libraries a quick search found me He.js

– 3limin4t0r
Mar 27 at 20:08




1




1





I've seen this behavior myself for more than two weeks now. My understanding is that this issue is in fact a bug of the API. Maybe you should file a bug report to issuetracker.google.com.

– stvar
Mar 27 at 22:24





I've seen this behavior myself for more than two weeks now. My understanding is that this issue is in fact a bug of the API. Maybe you should file a bug report to issuetracker.google.com.

– stvar
Mar 27 at 22:24













Searched the google issue tracker and found this: issuetracker.google.com/u/1/issues/128673539

– rami dulman
Mar 28 at 16:24






Searched the google issue tracker and found this: issuetracker.google.com/u/1/issues/128673539

– rami dulman
Mar 28 at 16:24














@ramidulman That is not the same issue. JSON strings must escape the double quote character using a backslash if the string itself contains this character. eg """ is not valid while """ is valid. The linked issue has nothing to do with HTML encoding.

– 3limin4t0r
Mar 29 at 18:13





@ramidulman That is not the same issue. JSON strings must escape the double quote character using a backslash if the string itself contains this character. eg """ is not valid while """ is valid. The linked issue has nothing to do with HTML encoding.

– 3limin4t0r
Mar 29 at 18:13













@3limin4t0r: sorry, but you are wrong: rami dulman did linked correctly his issue to Google's issue #128673539. See my comment issuetracker.google.com/issues/128673539#comment8.

– stvar
Mar 29 at 20:41






@3limin4t0r: sorry, but you are wrong: rami dulman did linked correctly his issue to Google's issue #128673539. See my comment issuetracker.google.com/issues/128673539#comment8.

– stvar
Mar 29 at 20:41













2 Answers
2






active

oldest

votes


















0















You can use the the DOM Parser



var parser = new DOMParser;

let finalResult = parser.parseFromString(results, "text/html")
console.log(finalResult.body.innerHtml); // will turn & to &





share|improve this answer



























  • I updated it...

    – Chris Hawkes
    Mar 27 at 20:19











  • This works, but I'm wondering whether this is the correct solution, do I need to use a whole DOMParser just for decoding Youtube video titles in my React component?

    – JBK
    7 hours ago











  • Seems like @ErikAGriffin mentioned an alternative library which is much smaller - unescape. github.com/jonschlinkert/unescape EDIT: found a more recent package by the known sindresorhus, was updated 3 months ago vs unescape's 2 years ago. npmjs.com/package/escape-goat

    – JBK
    7 hours ago



















0















After finding a related ticket on google's issue tracker:
issuetracker.google.com/u/1/issues/128673539 and got a response from google that this is the expected behaviour and they won't fix it, i just used user 3limin4t0r suggestion and decoded the return value title using he.js library, it's the idle way to solve this but i had no intention to wait for google to come around from their decision...



so, my solution goes like that:



var youtubeSearch = require("youtube-search")
let he = require('he');

var opts =
maxResults : 15,
key : 'MY_API_KEY',
part : 'snippet',
type : 'video',
;

youtubeSearch('post malone', opts, function(err, results)
if(err) return console.log(err);
results = results.map(item =>
item.snippet.title = he.decode(item.snippet.title);
return item;
);
console.dir(results);
);





share|improve this answer






















  • 1





    This library is significantly smaller if all you need is to unescape html entities: unescape

    – ErikAGriffin
    Jul 6 at 5:48













Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55385560%2fhow-to-fix-youtube-api-results-title-that-are-returned-encoded%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0















You can use the the DOM Parser



var parser = new DOMParser;

let finalResult = parser.parseFromString(results, "text/html")
console.log(finalResult.body.innerHtml); // will turn & to &





share|improve this answer



























  • I updated it...

    – Chris Hawkes
    Mar 27 at 20:19











  • This works, but I'm wondering whether this is the correct solution, do I need to use a whole DOMParser just for decoding Youtube video titles in my React component?

    – JBK
    7 hours ago











  • Seems like @ErikAGriffin mentioned an alternative library which is much smaller - unescape. github.com/jonschlinkert/unescape EDIT: found a more recent package by the known sindresorhus, was updated 3 months ago vs unescape's 2 years ago. npmjs.com/package/escape-goat

    – JBK
    7 hours ago
















0















You can use the the DOM Parser



var parser = new DOMParser;

let finalResult = parser.parseFromString(results, "text/html")
console.log(finalResult.body.innerHtml); // will turn & to &





share|improve this answer



























  • I updated it...

    – Chris Hawkes
    Mar 27 at 20:19











  • This works, but I'm wondering whether this is the correct solution, do I need to use a whole DOMParser just for decoding Youtube video titles in my React component?

    – JBK
    7 hours ago











  • Seems like @ErikAGriffin mentioned an alternative library which is much smaller - unescape. github.com/jonschlinkert/unescape EDIT: found a more recent package by the known sindresorhus, was updated 3 months ago vs unescape's 2 years ago. npmjs.com/package/escape-goat

    – JBK
    7 hours ago














0














0










0









You can use the the DOM Parser



var parser = new DOMParser;

let finalResult = parser.parseFromString(results, "text/html")
console.log(finalResult.body.innerHtml); // will turn & to &





share|improve this answer















You can use the the DOM Parser



var parser = new DOMParser;

let finalResult = parser.parseFromString(results, "text/html")
console.log(finalResult.body.innerHtml); // will turn & to &






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 27 at 20:22

























answered Mar 27 at 20:06









Chris HawkesChris Hawkes

7,0273 gold badges35 silver badges53 bronze badges




7,0273 gold badges35 silver badges53 bronze badges















  • I updated it...

    – Chris Hawkes
    Mar 27 at 20:19











  • This works, but I'm wondering whether this is the correct solution, do I need to use a whole DOMParser just for decoding Youtube video titles in my React component?

    – JBK
    7 hours ago











  • Seems like @ErikAGriffin mentioned an alternative library which is much smaller - unescape. github.com/jonschlinkert/unescape EDIT: found a more recent package by the known sindresorhus, was updated 3 months ago vs unescape's 2 years ago. npmjs.com/package/escape-goat

    – JBK
    7 hours ago


















  • I updated it...

    – Chris Hawkes
    Mar 27 at 20:19











  • This works, but I'm wondering whether this is the correct solution, do I need to use a whole DOMParser just for decoding Youtube video titles in my React component?

    – JBK
    7 hours ago











  • Seems like @ErikAGriffin mentioned an alternative library which is much smaller - unescape. github.com/jonschlinkert/unescape EDIT: found a more recent package by the known sindresorhus, was updated 3 months ago vs unescape's 2 years ago. npmjs.com/package/escape-goat

    – JBK
    7 hours ago

















I updated it...

– Chris Hawkes
Mar 27 at 20:19





I updated it...

– Chris Hawkes
Mar 27 at 20:19













This works, but I'm wondering whether this is the correct solution, do I need to use a whole DOMParser just for decoding Youtube video titles in my React component?

– JBK
7 hours ago





This works, but I'm wondering whether this is the correct solution, do I need to use a whole DOMParser just for decoding Youtube video titles in my React component?

– JBK
7 hours ago













Seems like @ErikAGriffin mentioned an alternative library which is much smaller - unescape. github.com/jonschlinkert/unescape EDIT: found a more recent package by the known sindresorhus, was updated 3 months ago vs unescape's 2 years ago. npmjs.com/package/escape-goat

– JBK
7 hours ago






Seems like @ErikAGriffin mentioned an alternative library which is much smaller - unescape. github.com/jonschlinkert/unescape EDIT: found a more recent package by the known sindresorhus, was updated 3 months ago vs unescape's 2 years ago. npmjs.com/package/escape-goat

– JBK
7 hours ago














0















After finding a related ticket on google's issue tracker:
issuetracker.google.com/u/1/issues/128673539 and got a response from google that this is the expected behaviour and they won't fix it, i just used user 3limin4t0r suggestion and decoded the return value title using he.js library, it's the idle way to solve this but i had no intention to wait for google to come around from their decision...



so, my solution goes like that:



var youtubeSearch = require("youtube-search")
let he = require('he');

var opts =
maxResults : 15,
key : 'MY_API_KEY',
part : 'snippet',
type : 'video',
;

youtubeSearch('post malone', opts, function(err, results)
if(err) return console.log(err);
results = results.map(item =>
item.snippet.title = he.decode(item.snippet.title);
return item;
);
console.dir(results);
);





share|improve this answer






















  • 1





    This library is significantly smaller if all you need is to unescape html entities: unescape

    – ErikAGriffin
    Jul 6 at 5:48















0















After finding a related ticket on google's issue tracker:
issuetracker.google.com/u/1/issues/128673539 and got a response from google that this is the expected behaviour and they won't fix it, i just used user 3limin4t0r suggestion and decoded the return value title using he.js library, it's the idle way to solve this but i had no intention to wait for google to come around from their decision...



so, my solution goes like that:



var youtubeSearch = require("youtube-search")
let he = require('he');

var opts =
maxResults : 15,
key : 'MY_API_KEY',
part : 'snippet',
type : 'video',
;

youtubeSearch('post malone', opts, function(err, results)
if(err) return console.log(err);
results = results.map(item =>
item.snippet.title = he.decode(item.snippet.title);
return item;
);
console.dir(results);
);





share|improve this answer






















  • 1





    This library is significantly smaller if all you need is to unescape html entities: unescape

    – ErikAGriffin
    Jul 6 at 5:48













0














0










0









After finding a related ticket on google's issue tracker:
issuetracker.google.com/u/1/issues/128673539 and got a response from google that this is the expected behaviour and they won't fix it, i just used user 3limin4t0r suggestion and decoded the return value title using he.js library, it's the idle way to solve this but i had no intention to wait for google to come around from their decision...



so, my solution goes like that:



var youtubeSearch = require("youtube-search")
let he = require('he');

var opts =
maxResults : 15,
key : 'MY_API_KEY',
part : 'snippet',
type : 'video',
;

youtubeSearch('post malone', opts, function(err, results)
if(err) return console.log(err);
results = results.map(item =>
item.snippet.title = he.decode(item.snippet.title);
return item;
);
console.dir(results);
);





share|improve this answer















After finding a related ticket on google's issue tracker:
issuetracker.google.com/u/1/issues/128673539 and got a response from google that this is the expected behaviour and they won't fix it, i just used user 3limin4t0r suggestion and decoded the return value title using he.js library, it's the idle way to solve this but i had no intention to wait for google to come around from their decision...



so, my solution goes like that:



var youtubeSearch = require("youtube-search")
let he = require('he');

var opts =
maxResults : 15,
key : 'MY_API_KEY',
part : 'snippet',
type : 'video',
;

youtubeSearch('post malone', opts, function(err, results)
if(err) return console.log(err);
results = results.map(item =>
item.snippet.title = he.decode(item.snippet.title);
return item;
);
console.dir(results);
);






share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 4 at 9:04

























answered Apr 4 at 8:25









rami dulmanrami dulman

112 bronze badges




112 bronze badges










  • 1





    This library is significantly smaller if all you need is to unescape html entities: unescape

    – ErikAGriffin
    Jul 6 at 5:48












  • 1





    This library is significantly smaller if all you need is to unescape html entities: unescape

    – ErikAGriffin
    Jul 6 at 5:48







1




1





This library is significantly smaller if all you need is to unescape html entities: unescape

– ErikAGriffin
Jul 6 at 5:48





This library is significantly smaller if all you need is to unescape html entities: unescape

– ErikAGriffin
Jul 6 at 5:48

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55385560%2fhow-to-fix-youtube-api-results-title-that-are-returned-encoded%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript