From 5822dad7e09d803c6d843f138255b2bce99eabdc Mon Sep 17 00:00:00 2001 From: Jonathan Hornung Date: Wed, 3 Feb 2016 19:34:04 +0100 Subject: [PATCH] impr: allow more params (close #8 & close #9) --- README.md | 24 +++++ bower.json | 2 +- dist/angular-youtube-api-factory.js | 118 +++++++++++++++++++----- dist/angular-youtube-api-factory.min.js | 4 +- package.json | 2 +- src/angular-youtube-api-factory.js | 116 +++++++++++++++++++---- 6 files changed, 221 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index cefce51..11ff844 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ Author: Jonathan Hornung ([JohnnyTheTank](https://github.com/JohnnyTheTank)) //docs: https://developers.google.com/youtube/v3/docs/videos/list youtubeFactory.getVideoById({ videoId: "", + part: "", // (optional) default: 'id,snippet,contentDetails,statistics' key: "", }).then(function (_data) { //on success @@ -48,8 +49,18 @@ youtubeFactory.getVideosFromChannelById({ channelId: "", q: "", // (optional) filters the channel result with your search string order: "", // (optional) valid values: 'date', 'rating', 'relevance', 'title', 'videoCount', 'viewCount' | default: 'date' + publishedAfter: "", // (optional) RFC 3339 formatted date-time value (1970-01-01T00:00:00Z) + publishedBefore: "", // (optional) RFC 3339 formatted date-time value (1970-01-01T00:00:00Z) + regionCode: "", // (optional) ISO 3166-1 alpha-2 country code + relevanceLanguage: "", // (optional) ISO 639-1 two-letter language code + safeSearch: "", // (optional) valid values: 'moderate','none','strict' | defaut: 'moderate' maxResults: "", // (optional) valid values: 0-50 | default: 5 + videoEmbeddable: "", // (optional) valid values: 'true', 'any' | default: 'true' + videoLicense: "", // (optional) valid values: 'any','creativeCommon','youtube' + videoSyndicated: "", // (optional) restrict a search to only videos that can be played outside youtube.com. valid values: 'any','true' | default: 'any' + fields: "", // (optional) Selector specifying which fields to include in a partial response pageToken: "", // (optional) + part: "", // (optional) default: 'id,snippet' key: "", }).then(function (_data) { //on success @@ -66,7 +77,18 @@ youtubeFactory.getVideosFromSearchByParams({ locationRadius: "", // (optional) valid values e.g. '1500m', '5km', '10000ft', and '0.75mi' | default: '5000m' order: "", // (optional) valid values: 'date', 'rating', 'relevance', 'title', 'videoCount', 'viewCount' | default: 'date' maxResults: "", // (optional) valid values: 0-50 | default: 5 + publishedAfter: "", // (optional) RFC 3339 formatted date-time value (1970-01-01T00:00:00Z) + publishedBefore: "", // (optional) RFC 3339 formatted date-time value (1970-01-01T00:00:00Z) + regionCode: "", // (optional) ISO 3166-1 alpha-2 country code + relevanceLanguage: "", // (optional) ISO 639-1 two-letter language code + safeSearch: "", // (optional) valid values: 'moderate','none','strict' | defaut: 'moderate' + maxResults: "", // (optional) valid values: 0-50 | default: 5 + videoEmbeddable: "", // (optional) valid values: 'true', 'any' | default: 'true' + videoLicense: "", // (optional) valid values: 'any','creativeCommon','youtube' + videoSyndicated: "", // (optional) restrict a search to only videos that can be played outside youtube.com. valid values: 'any','true' | default: 'any' + fields: "", // (optional) Selector specifying which fields to include in a partial response pageToken: "", // (optional) + part: "", // (optional) default: 'id,snippet' key: "", }).then(function (_data) { //on success @@ -81,6 +103,7 @@ youtubeFactory.getVideosFromPlaylistById({ playlistId: "", maxResults: "", // (optional) valid values: 0-50 // default: 5 pageToken: "", // (optional) + part: "", // (optional) default: 'id,snippet' key: "", }).then(function (_data) { //on success @@ -96,6 +119,7 @@ youtubeFactory.getVideosFromPlaylistById({ youtubeFactory.getChannelById({ channelId: "", pageToken: "", // (optional) + part: "", // (optional) default: 'id,snippet' key: "", }).then(function (_data) { //on success diff --git a/bower.json b/bower.json index 27eb50c..d7afe51 100644 --- a/bower.json +++ b/bower.json @@ -4,7 +4,7 @@ "authors": [ "Jonathan Hornung " ], - "version": "0.5.0", + "version": "0.6.0", "description": "angular factory for youtube rest api connection", "main": "dist/angular-youtube-api-factory.min.js", "moduleType": [], diff --git a/dist/angular-youtube-api-factory.js b/dist/angular-youtube-api-factory.js index 5671814..7b30486 100644 --- a/dist/angular-youtube-api-factory.js +++ b/dist/angular-youtube-api-factory.js @@ -1,6 +1,6 @@ /** @name: angular-youtube-api-factory - @version: 0.5.0 (06-01-2016) + @version: 0.6.0 (03-02-2016) @author: Jonathan Hornung @url: https://github.com/JohnnyTheTank/angular-youtube-api-factory#readme @license: MIT @@ -78,94 +78,170 @@ angular.module("jtt_youtube", []) var youtubeSearchData = { object: { - part: "id,snippet", key: _params.key, }, url: "", }; + if (angular.isDefined(_params.part)) { + youtubeSearchData.object.part = _params.part; + } + switch (_type) { case "videosFromChannelById": + if (angular.isUndefined(_params.part)) { + youtubeSearchData.object.part = "id,snippet"; + } youtubeSearchData.object.type = "video"; youtubeSearchData.object.channelId = _params.channelId; - if (typeof _params.order !== "undefined") { + if (angular.isDefined(_params.order)) { youtubeSearchData.object.order = _params.order; } else { youtubeSearchData.object.order = "date"; } - if (typeof _params.q !== "undefined") { + if (angular.isDefined(_params.q)) { youtubeSearchData.object.q = _params.q; } - if (typeof _params.maxResults !== "undefined") { + if (angular.isDefined(_params.maxResults)) { youtubeSearchData.object.maxResults = _params.maxResults; } + if (angular.isDefined(_params.publishedAfter)) { + youtubeSearchData.object.publishedAfter = _params.publishedAfter; + } + if (angular.isDefined(_params.publishedBefore)) { + youtubeSearchData.object.publishedBefore = _params.publishedBefore; + } + if (angular.isDefined(_params.regionCode)) { + youtubeSearchData.object.regionCode = _params.regionCode; + } + if (angular.isDefined(_params.relevanceLanguage)) { + youtubeSearchData.object.relevanceLanguage = _params.relevanceLanguage; + } + if (angular.isDefined(_params.safeSearch)) { + youtubeSearchData.object.safeSearch = _params.safeSearch; + } + if (angular.isDefined(_params.videoEmbeddable)) { + youtubeSearchData.object.videoEmbeddable = _params.videoEmbeddable; + } else { + youtubeSearchData.object.videoEmbeddable = true; + } + if (angular.isDefined(_params.videoLicense)) { + youtubeSearchData.object.videoLicense = _params.videoLicense; + } + if (angular.isDefined(_params.videoSyndicated)) { + youtubeSearchData.object.videoSyndicated = _params.videoSyndicated; + } + if (angular.isDefined(_params.fields)) { + youtubeSearchData.object.fields = _params.fields; + } youtubeSearchData.url = this.getApiBaseUrl() + "search?"; - if (typeof _params.nextPageToken !== "undefined") { + if (angular.isDefined(_params.nextPageToken)) { youtubeSearchData.url += "pageToken=" + _params.nextPageToken + "&"; } break; case "videosFromSearchByParams": + if (angular.isUndefined(_params.part)) { + youtubeSearchData.object.part = "id,snippet"; + } youtubeSearchData.object.type = "video"; - if (typeof _params.order !== "undefined") { + if (angular.isDefined(_params.order)) { youtubeSearchData.object.order = _params.order; } else { youtubeSearchData.object.order = "date"; } - if (typeof _params.q !== "undefined") { + if (angular.isDefined(_params.q)) { youtubeSearchData.object.q = _params.q; } - if (typeof _params.location !== "undefined") { + if (angular.isDefined(_params.location)) { youtubeSearchData.object.location = _params.location; } - if (typeof _params.locationRadius !== "undefined") { + if (angular.isDefined(_params.locationRadius)) { youtubeSearchData.object.locationRadius = _params.locationRadius; } else { - if (typeof _params.location !== "undefined") { + if (angular.isDefined(_params.location)) { youtubeSearchData.object.locationRadius = "5000m" } } - if (typeof _params.maxResults !== "undefined") { + if (angular.isDefined(_params.maxResults)) { youtubeSearchData.object.maxResults = _params.maxResults; } + if (angular.isDefined(_params.publishedAfter)) { + youtubeSearchData.object.publishedAfter = _params.publishedAfter; + } + if (angular.isDefined(_params.publishedBefore)) { + youtubeSearchData.object.publishedBefore = _params.publishedBefore; + } + if (angular.isDefined(_params.regionCode)) { + youtubeSearchData.object.regionCode = _params.regionCode; + } + if (angular.isDefined(_params.relevanceLanguage)) { + youtubeSearchData.object.relevanceLanguage = _params.relevanceLanguage; + } + if (angular.isDefined(_params.safeSearch)) { + youtubeSearchData.object.safeSearch = _params.safeSearch; + } + if (angular.isDefined(_params.videoEmbeddable)) { + youtubeSearchData.object.videoEmbeddable = _params.videoEmbeddable; + } else { + youtubeSearchData.object.videoEmbeddable = true; + } + if (angular.isDefined(_params.videoLicense)) { + youtubeSearchData.object.videoLicense = _params.videoLicense; + } + if (angular.isDefined(_params.videoSyndicated)) { + youtubeSearchData.object.videoSyndicated = _params.videoSyndicated; + } + if (angular.isDefined(_params.fields)) { + youtubeSearchData.object.fields = _params.fields; + } - youtubeSearchData.url = this.getApiBaseUrl()+"search?"; - if (typeof _params.nextPageToken !== "undefined") { + youtubeSearchData.url = this.getApiBaseUrl() + "search?"; + if (angular.isDefined(_params.nextPageToken)) { youtubeSearchData.url += "pageToken=" + _params.nextPageToken + "&"; } break; case "videosFromPlaylistById": + if (angular.isUndefined(_params.part)) { + youtubeSearchData.object.part = "id,snippet"; + } youtubeSearchData.object.playlistId = _params.playlistId; youtubeSearchData.object.type = "video"; - if (typeof _params.maxResults !== "undefined") { + if (angular.isDefined(_params.maxResults)) { youtubeSearchData.object.maxResults = _params.maxResults; } - youtubeSearchData.url = this.getApiBaseUrl()+"playlistItems?"; - if (typeof _params.nextPageToken !== "undefined") { + youtubeSearchData.url = this.getApiBaseUrl() + "playlistItems?"; + if (angular.isDefined(_params.nextPageToken)) { youtubeSearchData.url += "pageToken=" + _params.nextPageToken + "&"; } break; case "videoById": + if (angular.isUndefined(_params.part)) { + youtubeSearchData.object.part = "id,snippet,contentDetails,statistics"; + } youtubeSearchData.object.id = _params.videoId; - youtubeSearchData.url = this.getApiBaseUrl()+"videos?"; - if (typeof _params.nextPageToken !== "undefined") { + youtubeSearchData.url = this.getApiBaseUrl() + "videos?"; + if (angular.isDefined(_params.nextPageToken)) { youtubeSearchData.url += "pageToken=" + _params.nextPageToken + "&"; } break; case "channelById": + if (angular.isUndefined(_params.part)) { + youtubeSearchData.object.part = "id,snippet"; + } youtubeSearchData.object.type = "channel"; - youtubeSearchData.url = this.getApiBaseUrl()+"search?"; - if (typeof _params.nextPageToken !== "undefined") { + youtubeSearchData.url = this.getApiBaseUrl() + "search?"; + if (angular.isDefined(_params.nextPageToken)) { youtubeSearchData.url += "pageToken=" + _params.nextPageToken + "&"; } break; diff --git a/dist/angular-youtube-api-factory.min.js b/dist/angular-youtube-api-factory.min.js index d1a0d18..e38ac7e 100644 --- a/dist/angular-youtube-api-factory.min.js +++ b/dist/angular-youtube-api-factory.min.js @@ -1,8 +1,8 @@ /** @name: angular-youtube-api-factory - @version: 0.5.0 (06-01-2016) + @version: 0.6.0 (03-02-2016) @author: Jonathan Hornung @url: https://github.com/JohnnyTheTank/angular-youtube-api-factory#readme @license: MIT */ -"use strict";angular.module("jtt_youtube",[]).factory("youtubeFactory",["$http","youtubeSearchDataService",function(a,b){var c={};return c.getVideosFromChannelById=function(c){var d=b.getNew("videosFromChannelById",c);return a({method:"GET",url:d.url,params:d.object})},c.getVideosFromSearchByParams=function(c){var d=b.getNew("videosFromSearchByParams",c);return a({method:"GET",url:d.url,params:d.object})},c.getVideosFromPlaylistById=function(c){var d=b.getNew("videosFromPlaylistById",c);return a({method:"GET",url:d.url,params:d.object})},c.getChannelById=function(c){var d=b.getNew("channelById",c);return a({method:"GET",url:d.url,params:d.object})},c.getVideoById=function(c){var d=b.getNew("videoById",c);return a({method:"GET",url:d.url,params:d.object})},c}]).service("youtubeSearchDataService",function(){this.getApiBaseUrl=function(a){return"https://content.googleapis.com/youtube/v3/"},this.getNew=function(a,b){var c={object:{part:"id,snippet",key:b.key},url:""};switch(a){case"videosFromChannelById":c.object.type="video",c.object.channelId=b.channelId,"undefined"!=typeof b.order?c.object.order=b.order:c.object.order="date","undefined"!=typeof b.q&&(c.object.q=b.q),"undefined"!=typeof b.maxResults&&(c.object.maxResults=b.maxResults),c.url=this.getApiBaseUrl()+"search?","undefined"!=typeof b.nextPageToken&&(c.url+="pageToken="+b.nextPageToken+"&");break;case"videosFromSearchByParams":c.object.type="video","undefined"!=typeof b.order?c.object.order=b.order:c.object.order="date","undefined"!=typeof b.q&&(c.object.q=b.q),"undefined"!=typeof b.location&&(c.object.location=b.location),"undefined"!=typeof b.locationRadius?c.object.locationRadius=b.locationRadius:"undefined"!=typeof b.location&&(c.object.locationRadius="5000m"),"undefined"!=typeof b.maxResults&&(c.object.maxResults=b.maxResults),c.url=this.getApiBaseUrl()+"search?","undefined"!=typeof b.nextPageToken&&(c.url+="pageToken="+b.nextPageToken+"&");break;case"videosFromPlaylistById":c.object.playlistId=b.playlistId,c.object.type="video","undefined"!=typeof b.maxResults&&(c.object.maxResults=b.maxResults),c.url=this.getApiBaseUrl()+"playlistItems?","undefined"!=typeof b.nextPageToken&&(c.url+="pageToken="+b.nextPageToken+"&");break;case"videoById":c.object.id=b.videoId,c.url=this.getApiBaseUrl()+"videos?","undefined"!=typeof b.nextPageToken&&(c.url+="pageToken="+b.nextPageToken+"&");break;case"channelById":c.object.type="channel",c.url=this.getApiBaseUrl()+"search?","undefined"!=typeof b.nextPageToken&&(c.url+="pageToken="+b.nextPageToken+"&")}return c}}); \ No newline at end of file +"use strict";angular.module("jtt_youtube",[]).factory("youtubeFactory",["$http","youtubeSearchDataService",function(a,b){var c={};return c.getVideosFromChannelById=function(c){var d=b.getNew("videosFromChannelById",c);return a({method:"GET",url:d.url,params:d.object})},c.getVideosFromSearchByParams=function(c){var d=b.getNew("videosFromSearchByParams",c);return a({method:"GET",url:d.url,params:d.object})},c.getVideosFromPlaylistById=function(c){var d=b.getNew("videosFromPlaylistById",c);return a({method:"GET",url:d.url,params:d.object})},c.getChannelById=function(c){var d=b.getNew("channelById",c);return a({method:"GET",url:d.url,params:d.object})},c.getVideoById=function(c){var d=b.getNew("videoById",c);return a({method:"GET",url:d.url,params:d.object})},c}]).service("youtubeSearchDataService",function(){this.getApiBaseUrl=function(a){return"https://content.googleapis.com/youtube/v3/"},this.getNew=function(a,b){var c={object:{key:b.key},url:""};switch(angular.isDefined(b.part)&&(c.object.part=b.part),a){case"videosFromChannelById":angular.isUndefined(b.part)&&(c.object.part="id,snippet"),c.object.type="video",c.object.channelId=b.channelId,angular.isDefined(b.order)?c.object.order=b.order:c.object.order="date",angular.isDefined(b.q)&&(c.object.q=b.q),angular.isDefined(b.maxResults)&&(c.object.maxResults=b.maxResults),angular.isDefined(b.publishedAfter)&&(c.object.publishedAfter=b.publishedAfter),angular.isDefined(b.publishedBefore)&&(c.object.publishedBefore=b.publishedBefore),angular.isDefined(b.regionCode)&&(c.object.regionCode=b.regionCode),angular.isDefined(b.relevanceLanguage)&&(c.object.relevanceLanguage=b.relevanceLanguage),angular.isDefined(b.safeSearch)&&(c.object.safeSearch=b.safeSearch),angular.isDefined(b.videoEmbeddable)?c.object.videoEmbeddable=b.videoEmbeddable:c.object.videoEmbeddable=!0,angular.isDefined(b.videoLicense)&&(c.object.videoLicense=b.videoLicense),angular.isDefined(b.videoSyndicated)&&(c.object.videoSyndicated=b.videoSyndicated),angular.isDefined(b.fields)&&(c.object.fields=b.fields),c.url=this.getApiBaseUrl()+"search?",angular.isDefined(b.nextPageToken)&&(c.url+="pageToken="+b.nextPageToken+"&");break;case"videosFromSearchByParams":angular.isUndefined(b.part)&&(c.object.part="id,snippet"),c.object.type="video",angular.isDefined(b.order)?c.object.order=b.order:c.object.order="date",angular.isDefined(b.q)&&(c.object.q=b.q),angular.isDefined(b.location)&&(c.object.location=b.location),angular.isDefined(b.locationRadius)?c.object.locationRadius=b.locationRadius:angular.isDefined(b.location)&&(c.object.locationRadius="5000m"),angular.isDefined(b.maxResults)&&(c.object.maxResults=b.maxResults),angular.isDefined(b.publishedAfter)&&(c.object.publishedAfter=b.publishedAfter),angular.isDefined(b.publishedBefore)&&(c.object.publishedBefore=b.publishedBefore),angular.isDefined(b.regionCode)&&(c.object.regionCode=b.regionCode),angular.isDefined(b.relevanceLanguage)&&(c.object.relevanceLanguage=b.relevanceLanguage),angular.isDefined(b.safeSearch)&&(c.object.safeSearch=b.safeSearch),angular.isDefined(b.videoEmbeddable)?c.object.videoEmbeddable=b.videoEmbeddable:c.object.videoEmbeddable=!0,angular.isDefined(b.videoLicense)&&(c.object.videoLicense=b.videoLicense),angular.isDefined(b.videoSyndicated)&&(c.object.videoSyndicated=b.videoSyndicated),angular.isDefined(b.fields)&&(c.object.fields=b.fields),c.url=this.getApiBaseUrl()+"search?",angular.isDefined(b.nextPageToken)&&(c.url+="pageToken="+b.nextPageToken+"&");break;case"videosFromPlaylistById":angular.isUndefined(b.part)&&(c.object.part="id,snippet"),c.object.playlistId=b.playlistId,c.object.type="video",angular.isDefined(b.maxResults)&&(c.object.maxResults=b.maxResults),c.url=this.getApiBaseUrl()+"playlistItems?",angular.isDefined(b.nextPageToken)&&(c.url+="pageToken="+b.nextPageToken+"&");break;case"videoById":angular.isUndefined(b.part)&&(c.object.part="id,snippet,contentDetails,statistics"),c.object.id=b.videoId,c.url=this.getApiBaseUrl()+"videos?",angular.isDefined(b.nextPageToken)&&(c.url+="pageToken="+b.nextPageToken+"&");break;case"channelById":angular.isUndefined(b.part)&&(c.object.part="id,snippet"),c.object.type="channel",c.url=this.getApiBaseUrl()+"search?",angular.isDefined(b.nextPageToken)&&(c.url+="pageToken="+b.nextPageToken+"&")}return c}}); \ No newline at end of file diff --git a/package.json b/package.json index 6fc5677..2d2a544 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-youtube-api-factory", - "version": "0.5.0", + "version": "0.6.0", "description": "angularjs factory for youtube json rest api requests", "main": "dist/angular-youtube-api-factory.min.js", "scripts": { diff --git a/src/angular-youtube-api-factory.js b/src/angular-youtube-api-factory.js index 0c62c9e..df34bc9 100644 --- a/src/angular-youtube-api-factory.js +++ b/src/angular-youtube-api-factory.js @@ -71,94 +71,170 @@ angular.module("jtt_youtube", []) var youtubeSearchData = { object: { - part: "id,snippet", key: _params.key, }, url: "", }; + if (angular.isDefined(_params.part)) { + youtubeSearchData.object.part = _params.part; + } + switch (_type) { case "videosFromChannelById": + if (angular.isUndefined(_params.part)) { + youtubeSearchData.object.part = "id,snippet"; + } youtubeSearchData.object.type = "video"; youtubeSearchData.object.channelId = _params.channelId; - if (typeof _params.order !== "undefined") { + if (angular.isDefined(_params.order)) { youtubeSearchData.object.order = _params.order; } else { youtubeSearchData.object.order = "date"; } - if (typeof _params.q !== "undefined") { + if (angular.isDefined(_params.q)) { youtubeSearchData.object.q = _params.q; } - if (typeof _params.maxResults !== "undefined") { + if (angular.isDefined(_params.maxResults)) { youtubeSearchData.object.maxResults = _params.maxResults; } + if (angular.isDefined(_params.publishedAfter)) { + youtubeSearchData.object.publishedAfter = _params.publishedAfter; + } + if (angular.isDefined(_params.publishedBefore)) { + youtubeSearchData.object.publishedBefore = _params.publishedBefore; + } + if (angular.isDefined(_params.regionCode)) { + youtubeSearchData.object.regionCode = _params.regionCode; + } + if (angular.isDefined(_params.relevanceLanguage)) { + youtubeSearchData.object.relevanceLanguage = _params.relevanceLanguage; + } + if (angular.isDefined(_params.safeSearch)) { + youtubeSearchData.object.safeSearch = _params.safeSearch; + } + if (angular.isDefined(_params.videoEmbeddable)) { + youtubeSearchData.object.videoEmbeddable = _params.videoEmbeddable; + } else { + youtubeSearchData.object.videoEmbeddable = true; + } + if (angular.isDefined(_params.videoLicense)) { + youtubeSearchData.object.videoLicense = _params.videoLicense; + } + if (angular.isDefined(_params.videoSyndicated)) { + youtubeSearchData.object.videoSyndicated = _params.videoSyndicated; + } + if (angular.isDefined(_params.fields)) { + youtubeSearchData.object.fields = _params.fields; + } youtubeSearchData.url = this.getApiBaseUrl() + "search?"; - if (typeof _params.nextPageToken !== "undefined") { + if (angular.isDefined(_params.nextPageToken)) { youtubeSearchData.url += "pageToken=" + _params.nextPageToken + "&"; } break; case "videosFromSearchByParams": + if (angular.isUndefined(_params.part)) { + youtubeSearchData.object.part = "id,snippet"; + } youtubeSearchData.object.type = "video"; - if (typeof _params.order !== "undefined") { + if (angular.isDefined(_params.order)) { youtubeSearchData.object.order = _params.order; } else { youtubeSearchData.object.order = "date"; } - if (typeof _params.q !== "undefined") { + if (angular.isDefined(_params.q)) { youtubeSearchData.object.q = _params.q; } - if (typeof _params.location !== "undefined") { + if (angular.isDefined(_params.location)) { youtubeSearchData.object.location = _params.location; } - if (typeof _params.locationRadius !== "undefined") { + if (angular.isDefined(_params.locationRadius)) { youtubeSearchData.object.locationRadius = _params.locationRadius; } else { - if (typeof _params.location !== "undefined") { + if (angular.isDefined(_params.location)) { youtubeSearchData.object.locationRadius = "5000m" } } - if (typeof _params.maxResults !== "undefined") { + if (angular.isDefined(_params.maxResults)) { youtubeSearchData.object.maxResults = _params.maxResults; } + if (angular.isDefined(_params.publishedAfter)) { + youtubeSearchData.object.publishedAfter = _params.publishedAfter; + } + if (angular.isDefined(_params.publishedBefore)) { + youtubeSearchData.object.publishedBefore = _params.publishedBefore; + } + if (angular.isDefined(_params.regionCode)) { + youtubeSearchData.object.regionCode = _params.regionCode; + } + if (angular.isDefined(_params.relevanceLanguage)) { + youtubeSearchData.object.relevanceLanguage = _params.relevanceLanguage; + } + if (angular.isDefined(_params.safeSearch)) { + youtubeSearchData.object.safeSearch = _params.safeSearch; + } + if (angular.isDefined(_params.videoEmbeddable)) { + youtubeSearchData.object.videoEmbeddable = _params.videoEmbeddable; + } else { + youtubeSearchData.object.videoEmbeddable = true; + } + if (angular.isDefined(_params.videoLicense)) { + youtubeSearchData.object.videoLicense = _params.videoLicense; + } + if (angular.isDefined(_params.videoSyndicated)) { + youtubeSearchData.object.videoSyndicated = _params.videoSyndicated; + } + if (angular.isDefined(_params.fields)) { + youtubeSearchData.object.fields = _params.fields; + } - youtubeSearchData.url = this.getApiBaseUrl()+"search?"; - if (typeof _params.nextPageToken !== "undefined") { + youtubeSearchData.url = this.getApiBaseUrl() + "search?"; + if (angular.isDefined(_params.nextPageToken)) { youtubeSearchData.url += "pageToken=" + _params.nextPageToken + "&"; } break; case "videosFromPlaylistById": + if (angular.isUndefined(_params.part)) { + youtubeSearchData.object.part = "id,snippet"; + } youtubeSearchData.object.playlistId = _params.playlistId; youtubeSearchData.object.type = "video"; - if (typeof _params.maxResults !== "undefined") { + if (angular.isDefined(_params.maxResults)) { youtubeSearchData.object.maxResults = _params.maxResults; } - youtubeSearchData.url = this.getApiBaseUrl()+"playlistItems?"; - if (typeof _params.nextPageToken !== "undefined") { + youtubeSearchData.url = this.getApiBaseUrl() + "playlistItems?"; + if (angular.isDefined(_params.nextPageToken)) { youtubeSearchData.url += "pageToken=" + _params.nextPageToken + "&"; } break; case "videoById": + if (angular.isUndefined(_params.part)) { + youtubeSearchData.object.part = "id,snippet,contentDetails,statistics"; + } youtubeSearchData.object.id = _params.videoId; - youtubeSearchData.url = this.getApiBaseUrl()+"videos?"; - if (typeof _params.nextPageToken !== "undefined") { + youtubeSearchData.url = this.getApiBaseUrl() + "videos?"; + if (angular.isDefined(_params.nextPageToken)) { youtubeSearchData.url += "pageToken=" + _params.nextPageToken + "&"; } break; case "channelById": + if (angular.isUndefined(_params.part)) { + youtubeSearchData.object.part = "id,snippet"; + } youtubeSearchData.object.type = "channel"; - youtubeSearchData.url = this.getApiBaseUrl()+"search?"; - if (typeof _params.nextPageToken !== "undefined") { + youtubeSearchData.url = this.getApiBaseUrl() + "search?"; + if (angular.isDefined(_params.nextPageToken)) { youtubeSearchData.url += "pageToken=" + _params.nextPageToken + "&"; } break;