aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/apis/youtube/YoutubeBox.tsx63
-rw-r--r--src/server/youtubeApi/youtubeApiSample.js4
2 files changed, 35 insertions, 32 deletions
diff --git a/src/client/apis/youtube/YoutubeBox.tsx b/src/client/apis/youtube/YoutubeBox.tsx
index 414abcc15..8d6334c6e 100644
--- a/src/client/apis/youtube/YoutubeBox.tsx
+++ b/src/client/apis/youtube/YoutubeBox.tsx
@@ -58,37 +58,40 @@ export class YoutubeBox extends React.Component<FieldViewProps> {
let awaitedDetails = await castedDetailBackUp;
-
- let jsonList = await DocListCastAsync(awaitedBackUp!.json);
- let jsonDetailList = await DocListCastAsync(awaitedDetails!.json);
-
- if (jsonList!.length !== 0) {
- runInAction(() => this.searchResultsFound = true);
- let index = 0;
- //getting the necessary information from backUps and building templates that will be used to map in render
- for (let video of jsonList!) {
-
- let videoId = await Cast(video.id, Doc);
- let id = StrCast(videoId!.videoId);
- let snippet = await Cast(video.snippet, Doc);
- let videoTitle = this.filterYoutubeTitleResult(StrCast(snippet!.title));
- let thumbnail = await Cast(snippet!.thumbnails, Doc);
- let thumbnailMedium = await Cast(thumbnail!.medium, Doc);
- let thumbnailUrl = StrCast(thumbnailMedium!.url);
- let videoDescription = StrCast(snippet!.description);
- let pusblishDate = (this.roundPublishTime(StrCast(snippet!.publishedAt)))!;
- let channelTitle = StrCast(snippet!.channelTitle);
- let duration: string;
- let viewCount: string;
- if (jsonDetailList!.length !== 0) {
- let contentDetails = await Cast(jsonDetailList![index].contentDetails, Doc);
- let statistics = await Cast(jsonDetailList![index].statistics, Doc);
- duration = this.convertIsoTimeToDuration(StrCast(contentDetails!.duration));
- viewCount = this.abbreviateViewCount(NumCast(statistics!.viewCount))!;
+ if (awaitedBackUp) {
+
+
+ let jsonList = await DocListCastAsync(awaitedBackUp!.json);
+ let jsonDetailList = await DocListCastAsync(awaitedDetails!.json);
+
+ if (jsonList!.length !== 0) {
+ runInAction(() => this.searchResultsFound = true);
+ let index = 0;
+ //getting the necessary information from backUps and building templates that will be used to map in render
+ for (let video of jsonList!) {
+
+ let videoId = await Cast(video.id, Doc);
+ let id = StrCast(videoId!.videoId);
+ let snippet = await Cast(video.snippet, Doc);
+ let videoTitle = this.filterYoutubeTitleResult(StrCast(snippet!.title));
+ let thumbnail = await Cast(snippet!.thumbnails, Doc);
+ let thumbnailMedium = await Cast(thumbnail!.medium, Doc);
+ let thumbnailUrl = StrCast(thumbnailMedium!.url);
+ let videoDescription = StrCast(snippet!.description);
+ let pusblishDate = (this.roundPublishTime(StrCast(snippet!.publishedAt)))!;
+ let channelTitle = StrCast(snippet!.channelTitle);
+ let duration: string;
+ let viewCount: string;
+ if (jsonDetailList!.length !== 0) {
+ let contentDetails = await Cast(jsonDetailList![index].contentDetails, Doc);
+ let statistics = await Cast(jsonDetailList![index].statistics, Doc);
+ duration = this.convertIsoTimeToDuration(StrCast(contentDetails!.duration));
+ viewCount = this.abbreviateViewCount(NumCast(statistics!.viewCount))!;
+ }
+ index = index + 1;
+ let newTemplate: VideoTemplate = { videoId: id, videoTitle: videoTitle, thumbnailUrl: thumbnailUrl, publishDate: pusblishDate, channelTitle: channelTitle, videoDescription: videoDescription, duration: duration!, viewCount: viewCount! };
+ runInAction(() => this.curVideoTemplates.push(newTemplate));
}
- index = index + 1;
- let newTemplate: VideoTemplate = { videoId: id, videoTitle: videoTitle, thumbnailUrl: thumbnailUrl, publishDate: pusblishDate, channelTitle: channelTitle, videoDescription: videoDescription, duration: duration!, viewCount: viewCount! };
- runInAction(() => this.curVideoTemplates.push(newTemplate));
}
}
}
diff --git a/src/server/youtubeApi/youtubeApiSample.js b/src/server/youtubeApi/youtubeApiSample.js
index f81f0dfb5..9853241b6 100644
--- a/src/server/youtubeApi/youtubeApiSample.js
+++ b/src/server/youtubeApi/youtubeApiSample.js
@@ -28,7 +28,7 @@ module.exports.authorizedGetChannel = (apiKey) => {
}
module.exports.authorizedGetVideos = (apiKey, userInput, callBack) => {
- authorize(JSON.parse(apiKey), getSampleVideos, { userInput: userInput, callBack: callBack });
+ authorize(JSON.parse(apiKey), getVideos, { userInput: userInput, callBack: callBack });
}
module.exports.authorizedGetVideoDetails = (apiKey, videoIds, callBack) => {
@@ -141,7 +141,7 @@ function getChannel(auth) {
});
}
-function getSampleVideos(auth, args) {
+function getVideos(auth, args) {
let service = google.youtube('v3');
service.search.list({
auth: auth,