Skip to content

Commit

Permalink
bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyTheTank committed Sep 23, 2016
1 parent 62d28a6 commit 05c4ccb
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 175 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"authors": [
"Jonathan Hornung <jonathan.hornung@gmail.com>"
],
"version": "0.7.11",
"version": "0.7.12",
"description": "Youtube plugin for apiNG",
"main": "dist/angular-plugin-youtube.min.js",
"moduleType": [],
Expand Down
285 changes: 116 additions & 169 deletions dist/aping-plugin-youtube.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
@name: aping-plugin-youtube
@version: 0.7.11 (05-02-2016)
@version: 0.7.12 (24-09-2016)
@author: Jonathan Hornung <jonathan.hornung@gmail.com>
@url: https://github.com/JohnnyTheTank/apiNG-plugin-youtube
@license: MIT
Expand Down Expand Up @@ -149,14 +149,12 @@ angular.module("jtt_aping_youtube").service('apingYoutubeHelper', ['apingModels'
if (duration.indexOf('M') >= 0 && duration.indexOf('H') == -1 && duration.indexOf('S') == -1) {
a = [0, a[0], 0];
}

if (duration.indexOf('H') >= 0 && duration.indexOf('M') == -1) {
a = [a[0], 0, a[1]];
}
if (duration.indexOf('H') >= 0 && duration.indexOf('M') == -1 && duration.indexOf('S') == -1) {
a = [a[0], 0, 0];
}

duration = 0;

if (a.length == 3) {
Expand Down Expand Up @@ -332,244 +330,193 @@ angular.module("jtt_aping_youtube").service('apingYoutubeHelper', ['apingModels'

angular.module("jtt_youtube", [])
.factory('youtubeFactory', ['$http', 'youtubeSearchDataService', function ($http, youtubeSearchDataService) {

var youtubeFactory = {};

youtubeFactory.getVideosFromChannelById = function (_params) {

var youtubeSearchData = youtubeSearchDataService.getNew("videosFromChannelById", _params);

return $http({
method: 'GET',
url: youtubeSearchData.url,
params: youtubeSearchData.object,
});
};

youtubeFactory.getVideosFromSearchByParams = function (_params) {

var youtubeSearchData = youtubeSearchDataService.getNew("videosFromSearchByParams", _params);

return $http({
method: 'GET',
url: youtubeSearchData.url,
params: youtubeSearchData.object,
});
};

youtubeFactory.getVideosFromPlaylistById = function (_params) {

var youtubeSearchData = youtubeSearchDataService.getNew("videosFromPlaylistById", _params);

return $http({
method: 'GET',
url: youtubeSearchData.url,
params: youtubeSearchData.object,
});
};

youtubeFactory.getChannelById = function (_params) {

var youtubeSearchData = youtubeSearchDataService.getNew("channelById", _params);

return $http({
method: 'GET',
url: youtubeSearchData.url,
params: youtubeSearchData.object,
});
};

youtubeFactory.getVideoById = function (_params) {

var youtubeSearchData = youtubeSearchDataService.getNew("videoById", _params);

return $http({
method: 'GET',
url: youtubeSearchData.url,
params: youtubeSearchData.object,
});
};

return youtubeFactory;
}])
.service('youtubeSearchDataService', function () {
this.getApiBaseUrl = function (_params) {
return "https://content.googleapis.com/youtube/v3/";
};


this.fillDataInObjectByList = function (_object, _params, _list) {

angular.forEach(_list, function (value, key) {
if (typeof value !== "undefined" && value.constructor === Array) {
if (angular.isDefined(_params[value[0]])) {
_object.object[value[0]] = _params[value[0]];
} else {
_object.object[value[0]] = value[1];
}
} else {
if (angular.isDefined(_params[value])) {
_object.object[value] = _params[value];
}
}
});

return _object;
};

this.getNew = function (_type, _params) {

var youtubeSearchData = {
object: {
key: _params.key,
},
url: "",
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 (angular.isDefined(_params.order)) {
youtubeSearchData.object.order = _params.order;
} else {
youtubeSearchData.object.order = "date";
}
if (angular.isDefined(_params.q)) {
youtubeSearchData.object.q = _params.q;
}
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 (angular.isDefined(_params.nextPageToken)) {
youtubeSearchData.url += "pageToken=" + _params.nextPageToken + "&";
case 'videosFromChannelById':

youtubeSearchData = this.fillDataInObjectByList(youtubeSearchData, _params, [
['part', 'id,snippet'],
['type', 'video'],
['order', 'date'],
['videoEmbeddable', true],
'channelId',
'q',
'maxResults',
'publishedAfter',
'publishedBefore',
'regionCode',
'relevanceLanguage',
'safeSearch',
'videoLicense',
'videoSyndicated',
'fields'
]);

youtubeSearchData.url = this.getApiBaseUrl() + 'search?';

if (_params.nextPageToken || _params.prevPageToken) {
youtubeSearchData.url += 'pageToken=' + (_params.nextPageToken || _params.prevPageToken) + '&';
}
break;

case "videosFromSearchByParams":
if (angular.isUndefined(_params.part)) {
youtubeSearchData.object.part = "id,snippet";
}
youtubeSearchData.object.type = "video";
if (angular.isDefined(_params.order)) {
youtubeSearchData.object.order = _params.order;
} else {
youtubeSearchData.object.order = "date";
}
if (angular.isDefined(_params.q)) {
youtubeSearchData.object.q = _params.q;
}
if (angular.isDefined(_params.location)) {
youtubeSearchData.object.location = _params.location;
}

case 'videosFromSearchByParams':

youtubeSearchData = this.fillDataInObjectByList(youtubeSearchData, _params, [
['part', 'id,snippet'],
['type', 'video'],
['order', 'date'],
['videoEmbeddable', true],
'location',
'q',
'maxResults',
'publishedAfter',
'publishedBefore',
'regionCode',
'relevanceLanguage',
'safeSearch',
'videoLicense',
'videoSyndicated',
'fields'
]);

if (angular.isDefined(_params.locationRadius)) {
youtubeSearchData.object.locationRadius = _params.locationRadius;
} else {
if (angular.isDefined(_params.location)) {
youtubeSearchData.object.locationRadius = "5000m"
youtubeSearchData.object.locationRadius = '5000m'
}
}
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 (angular.isDefined(_params.nextPageToken)) {
youtubeSearchData.url += "pageToken=" + _params.nextPageToken + "&";

youtubeSearchData.url = this.getApiBaseUrl() + 'search?';
if (_params.nextPageToken || _params.prevPageToken) {
youtubeSearchData.url += 'pageToken=' + (_params.nextPageToken || _params.prevPageToken) + '&';
}
break;

case "videosFromPlaylistById":
if (angular.isUndefined(_params.part)) {
youtubeSearchData.object.part = "id,snippet";
}
youtubeSearchData.object.playlistId = _params.playlistId;
youtubeSearchData.object.type = "video";

if (angular.isDefined(_params.maxResults)) {
youtubeSearchData.object.maxResults = _params.maxResults;
}

youtubeSearchData.url = this.getApiBaseUrl() + "playlistItems?";
if (angular.isDefined(_params.nextPageToken)) {
youtubeSearchData.url += "pageToken=" + _params.nextPageToken + "&";

case 'videosFromPlaylistById':

youtubeSearchData = this.fillDataInObjectByList(youtubeSearchData, _params, [
['part', 'id,snippet'],
['type', 'video'],
'playlistId',
'maxResults',
'fields'
]);

youtubeSearchData.url = this.getApiBaseUrl() + 'playlistItems?';
if (_params.nextPageToken || _params.prevPageToken) {
youtubeSearchData.url += 'pageToken=' + (_params.nextPageToken || _params.prevPageToken) + '&';
}
break;

case "videoById":
if (angular.isUndefined(_params.part)) {
youtubeSearchData.object.part = "id,snippet,contentDetails,statistics";
}

case 'videoById':
youtubeSearchData = this.fillDataInObjectByList(youtubeSearchData, _params, [
['part', 'id,snippet,contentDetails,statistics'],
]);

youtubeSearchData.object.id = _params.videoId;

youtubeSearchData.url = this.getApiBaseUrl() + "videos?";
if (angular.isDefined(_params.nextPageToken)) {
youtubeSearchData.url += "pageToken=" + _params.nextPageToken + "&";
youtubeSearchData.url = this.getApiBaseUrl() + 'videos?';
if (_params.nextPageToken || _params.prevPageToken) {
youtubeSearchData.url += 'pageToken=' + (_params.nextPageToken || _params.prevPageToken) + '&';
}
break;

case "channelById":
if (angular.isUndefined(_params.part)) {
youtubeSearchData.object.part = "id,snippet";
}
youtubeSearchData.object.type = "channel";

youtubeSearchData.url = this.getApiBaseUrl() + "search?";
if (angular.isDefined(_params.nextPageToken)) {
youtubeSearchData.url += "pageToken=" + _params.nextPageToken + "&";
case 'channelById':
youtubeSearchData = this.fillDataInObjectByList(youtubeSearchData, _params, [
['part', 'id,snippet'],
['type', 'channel']
]);
youtubeSearchData.url = this.getApiBaseUrl() + 'search?';
if (_params.nextPageToken || _params.prevPageToken) {
youtubeSearchData.url += 'pageToken=' + (_params.nextPageToken || _params.prevPageToken) + '&';
}
break;
}

return youtubeSearchData;
};
});
Loading

0 comments on commit 05c4ccb

Please sign in to comment.