summaryrefslogtreecommitdiff
path: root/app/client
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2019-07-15 17:37:50 +0200
committerJules Laplace <julescarbon@gmail.com>2019-07-15 17:37:50 +0200
commit9c1f011fb187cd7ae77bc79a429b238c8b5fc570 (patch)
treed87acab85e447a73227f16b7e6401eccb30d98df /app/client
parentcb3d4041bf9e0c2a3ae9cc147c21afce06773a90 (diff)
fix api key
Diffstat (limited to 'app/client')
-rw-r--r--app/client/api/parser.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/app/client/api/parser.js b/app/client/api/parser.js
index d0e6aab..6c37794 100644
--- a/app/client/api/parser.js
+++ b/app/client/api/parser.js
@@ -90,7 +90,7 @@ export const integrations = [
const jsonp_url = new URL('https://www.googleapis.com/youtube/v3/videos')
const data = {
id: id,
- key: "AIzaSyCaLRGY-hxs92045X-Jew7w1FgQPkStHgc",
+ key: "AIzaSyA4UK3L2tZ5nHRUELEPk1PG13kxzZkc6qg",
part: "id,contentDetails,snippet,status",
}
Object.keys(data).forEach(key => jsonp_url.searchParams.append(key, data[key]))
@@ -98,21 +98,24 @@ export const integrations = [
fetchJsonp(jsonp_url.toString())
.then(result => result.json())
.then(result => {
- if (! result || ! result.items.length) {
+ console.log(result)
+ if (! result || ! result.items || ! result.items.length) {
return alert("Sorry, this video URL is invalid.")
}
var res = result.items[0]
// console.log(res)
var dd = res.contentDetails.duration.match(/\d+/g).map(function(i){ return parseInt(i) })
- var duration = 0
- if (dd.length == 3) {
+ var duration
+ console.log(res, dd)
+
+ if (!dd) {
+ duration = 0
+ } else if (dd.length == 3) {
duration = ((dd[0] * 60) + dd[1] * 60) + dd[2]
- }
- else if (dd.length == 2) {
+ } else if (dd.length == 2) {
duration = (dd[0] * 60) + dd[1]
- }
- else {
+ } else {
duration = dd[0]
}