Skip to content

Commit

Permalink
Fixed large videos list checking.
Browse files Browse the repository at this point in the history
  • Loading branch information
Plastiquewind committed Feb 2, 2018
1 parent 3cdef31 commit 118b462
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 73 deletions.
40 changes: 0 additions & 40 deletions app.106ac19c6d4ea97e33fe.js

This file was deleted.

1 change: 0 additions & 1 deletion app.106ac19c6d4ea97e33fe.js.map

This file was deleted.

43 changes: 43 additions & 0 deletions app.f7a65eefaa1a8dfc0604.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app.f7a65eefaa1a8dfc0604.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<span>Загрузка...</span>
</div>
<script src="https://apis.google.com/js/api.js"></script>
<script type="text/javascript" src="/vendor.106ac19c6d4ea97e33fe.js"></script><script type="text/javascript" src="/app.106ac19c6d4ea97e33fe.js"></script></body>
<script type="text/javascript" src="/vendor.f7a65eefaa1a8dfc0604.js"></script><script type="text/javascript" src="/app.f7a65eefaa1a8dfc0604.js"></script></body>

</html>
11 changes: 8 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "youlikeapp",
"version": "1.3.5",
"version": "1.3.6",
"author": {
"name": "Plastiquewind"
},
Expand All @@ -11,7 +11,7 @@
},
"scripts": {
"build": "rimraf dist && webpack --bail --progress --profile --NODE_ENV=production",
"server": "webpack-dev-server --https --history-api-fallback --inline --hot --progress --NODE_ENV=dev",
"server": "webpack-dev-server --history-api-fallback --inline --hot --progress --NODE_ENV=dev",
"start": "npm run server"
},
"devDependencies": {
Expand All @@ -25,6 +25,7 @@
"@types/gapi.auth2": "0.0.46",
"@types/gapi.client.youtube": "^3.0.0",
"@types/jquery": "^2.0.48",
"@types/lodash": "^4.14.100",
"@types/query-string": "^5.0.1",
"@types/toastr": "^2.1.35",
"@types/validator": "^6.3.0",
Expand Down Expand Up @@ -63,6 +64,7 @@
"angular-sanitize": "1.5.8",
"angular-socialshare": "^2.3.11",
"angular-ui-router": "1.0.0-beta.3",
"lodash": "^4.17.4",
"moment": "^2.20.1",
"query-string": "^5.0.1",
"toastr": "^2.1.4",
Expand Down
42 changes: 30 additions & 12 deletions src/app/common/youtube/youtube.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as queryString from "query-string";
import * as validator from "validator";
import * as toastr from "toastr";
import * as _ from "lodash";

export class YouTubeService {
private googleAuth: gapi.auth2.GoogleAuth;
Expand Down Expand Up @@ -55,32 +56,49 @@ export class YouTubeService {
return result;
});

// maximum possible batch size for the request is 580.
let videoIdsChunks: string[][] = _.chunk(videoIds, 580);

return gapi.client.load("youtube", "v3").then(() => {
return (<any>gapi.client).youtube.videos.getRating({
id: videoIds.join(",")
}).then((response) => response);
let promises: any[] = [];

videoIdsChunks.forEach((videoIdsChunk) => {
let promise: any = (<any>gapi.client).youtube.videos.getRating({
id: videoIdsChunk.join(",")
});

promises.push(promise);
});

return Promise.all(promises);
})
.then((response) => {
let items: gapi.client.youtube.VideoRating[] = response.result.items;
.then((responses) => {
let result: CheckingResult = new CheckingResult();
let withLikes: string[] = [];
let withoutLikes: string[] = [];

items.forEach((item) => {
if (item.rating !== "like") {
withoutLikes.push(item.videoId);
} else {
withLikes.push(item.videoId);
for (let i: number = 0; i < (<any>responses).length; i++) {
const response: any = (<any>responses)[i];
const items: gapi.client.youtube.VideoRating[] = response.result.items;

for (let i: number = 0; i < items.length; i++) {
const item: gapi.client.youtube.VideoRating = items[i];

if (item.rating !== "like") {
withoutLikes.push(item.videoId);
} else {
withLikes.push(item.videoId);
}
}
});
}

result.withLikes = withLikes;
result.withoutLikes = withoutLikes;

return result;
}, (data) => {
console.error(data);
toastr.error(`Не удалось проверить список видео. ${ data.result.error.message }`);
toastr.error(`Не удалось проверить список видео.`);

return null;
});
Expand Down
26 changes: 24 additions & 2 deletions src/app/components/extension/extension.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h1 class="md-headline">Установка расширения</h1>
Достаточно будет лишь нажать на кнопку "Добавить в YouLike",
расположенную под кнопками лайка и дизлайка.
</p>
<h2>Google Chrome</h2>
<h2><i class="fa fa-chrome"></i> Google Chrome</h2>
<p>
<a href="https://chrome.google.com/webstore/detail/youlike-%D0%B2%D0%BE%D1%81%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-%D0%BB%D0%B0/bpnhjhdmbhnjkhemgmfahahohblnombi"
target="_blank">
Expand All @@ -17,13 +17,35 @@ <h2>Google Chrome</h2>
<p>
По этой же ссылке можно установить расширение для Я.Браузер.
</p>
<h2>Mozilla Firefox</h2>
<h2><i class="fa fa-firefox"></i> Mozilla Firefox</h2>
<p>
<a href="https://addons.mozilla.org/ru/firefox/addon/youlike-%D0%B2%D0%BE%D1%81%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-%D0%BB%D0%B0%D0%B9%D0%BA%D0%BE%D0%B2/"
target="_blank">
Установить расширение для Mozilla Firefox
</a>
</p>
<h2><i class="fa fa-opera"></i> Opera</h2>
<div>
<p>
Модераторы Opera рассматривают расширение
<span class="strikethrough">дольше президентского срока Путина</span>,
но уже сейчас его можно установить из Chrome Web Store.
Для этого нужно сначала установить
<a href="https://addons.opera.com/ru/extensions/details/download-chrome-extension-9/" target="_blank">
Install Chrome Extensions
</a>, затем пройти по
<a href="https://chrome.google.com/webstore/detail/youlike-%D0%B2%D0%BE%D1%81%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-%D0%BB%D0%B0/bpnhjhdmbhnjkhemgmfahahohblnombi"
target="_blank">
этой ссылке
</a>
и нажать на кнопку "Установить".
</p>
<p>
Install Chrome Extensions выдаст сообщение о том, как завершить установку (читать необязательно).
После нажатия на "ОК" откроется страница расширений Opera, на которой появится расширение YouLike.
Останется лишь нажать на кнопку "Установить", расположенную справа от названия.
</p>
</div>
</md-content>
</div>
</div>
3 changes: 3 additions & 0 deletions src/app/components/extension/extension.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.strikethrough {
text-decoration-line: line-through;
}
20 changes: 10 additions & 10 deletions vendor.106ac19c6d4ea97e33fe.js → vendor.f7a65eefaa1a8dfc0604.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = (function makeWebpackConfig() {
path: isProd ? getPath("./") : getPath('./dist'),
filename: isProd ? '[name].[hash].js' : '[name].bundle.js',
chunkFilename: isProd ? '[name].[hash].js' : '[name].bundle.js',
publicPath: isProd ? '/' : 'https://localhost:8080/'
publicPath: isProd ? '/' : 'http://localhost:8080/'

};

Expand Down

0 comments on commit 118b462

Please sign in to comment.