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;
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
|
show 4 more comments
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
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
|
show 4 more comments
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
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
javascript node.js youtube-data-api
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
|
show 4 more comments
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
|
show 4 more comments
2 Answers
2
active
oldest
votes
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 &
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
add a comment |
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);
);
1
This library is significantly smaller if all you need is to unescape html entities: unescape
– ErikAGriffin
Jul 6 at 5:48
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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 &
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
add a comment |
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 &
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
add a comment |
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 &
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 &
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
add a comment |
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
add a comment |
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);
);
1
This library is significantly smaller if all you need is to unescape html entities: unescape
– ErikAGriffin
Jul 6 at 5:48
add a comment |
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);
);
1
This library is significantly smaller if all you need is to unescape html entities: unescape
– ErikAGriffin
Jul 6 at 5:48
add a comment |
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);
);
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);
);
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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