socialblade
Advanced tools
Comparing version 0.0.2 to 0.0.3
import { IClient } from './interfaces/client.interface'; | ||
import { IUser } from './interfaces/user.interface'; | ||
import { IDeveloper } from './interfaces/dev.interface'; | ||
import { IYouTubeStats } from './interfaces/ytstatsdata.interface'; | ||
export declare class SocialBladeClient { | ||
@@ -14,2 +15,3 @@ private Http; | ||
Auth(key: IClient['key']): Promise<IDeveloper>; | ||
StatsYouTube(identifier: string): Promise<IYouTubeStats>; | ||
} |
@@ -22,3 +22,4 @@ "use strict"; | ||
"Cache-Control": "no-cache", | ||
"User-Agent": this.UserAgent | ||
"User-Agent": this.UserAgent, | ||
"Authorization": this.Client.user ? `${this.Client.email}::${this.Client.token}` : this.Client.key | ||
} | ||
@@ -57,4 +58,69 @@ }); | ||
} | ||
async StatsYouTube(identifier) { | ||
const response = await this.Http.get({ | ||
uri: endpoints_1.Endpoints.YouTubeStats, | ||
qs: Object.assign({ query: `statistics`, username: identifier }, this.Client) | ||
}); | ||
let body = response.body; | ||
// Set proper types since everything is a string in the API. | ||
// #region data | ||
if (!body.data) | ||
return body; | ||
// toDate | ||
body.data.created_at = new Date(body.data.created_at); | ||
// toBoolean | ||
body.data.partner = !!+body.data.partner; | ||
body.data.isVerified = !!+body.data.isVerified; | ||
// toFloat | ||
body.data.avgdailysubs = parseFloat(body.data.avgdailysubs.toString()); | ||
body.data.avgdailyviews = parseFloat(body.data.avgdailyviews.toString()); | ||
// toNumber | ||
body.data.uploads = Number(body.data.uploads); | ||
body.data.subs = Number(body.data.subs); | ||
body.data.views = Number(body.data.views); | ||
// #endregion data | ||
// #region rank | ||
if (!body.rank) | ||
return body; | ||
// toNumber | ||
body.rank.raw.rank = Number(body.rank.raw.rank); | ||
body.rank.raw.sbrank = Number(body.rank.raw.sbrank); | ||
body.rank.raw.viewsrank = Number(body.rank.raw.viewsrank); | ||
body.rank.raw.countryrank = Number(body.rank.raw.countryrank); | ||
body.rank.raw.channeltyperank = Number(body.rank.raw.channeltyperank); | ||
// #endregion rank | ||
// #region charts | ||
if (!body.charts) | ||
return body; | ||
// toNumber -- Subs | ||
body.charts.subs.subs14 = Number(body.charts.subs.subs14); | ||
body.charts.subs.subs30 = Number(body.charts.subs.subs30); | ||
body.charts.subs.subs60 = Number(body.charts.subs.subs60); | ||
body.charts.subs.subs90 = Number(body.charts.subs.subs90); | ||
body.charts.subs.subs180 = Number(body.charts.subs.subs180); | ||
body.charts.subs.subs365 = Number(body.charts.subs.subs365); | ||
// Views | ||
body.charts.views.views14 = Number(body.charts.views.views14); | ||
body.charts.views.views30 = Number(body.charts.views.views30); | ||
body.charts.views.views60 = Number(body.charts.views.views60); | ||
body.charts.views.views90 = Number(body.charts.views.views90); | ||
body.charts.views.views180 = Number(body.charts.views.views180); | ||
body.charts.views.views365 = Number(body.charts.views.views365); | ||
// toFloat -- Growth | ||
body.charts.growth.subs = parseFloat(body.charts.growth.subs.toString()); | ||
body.charts.growth.views = parseFloat(body.charts.growth.views.toString()); | ||
// #endregion charts | ||
// #region data_daily | ||
if (!body.data_daily) | ||
return body; | ||
body.data_daily.map(item => { | ||
item.date = new Date(item.date); | ||
item.subs = Number(item.subs); | ||
item.views = Number(item.views); | ||
}); | ||
// #endregion data_daily | ||
return body; | ||
} | ||
} | ||
exports.SocialBladeClient = SocialBladeClient; | ||
//# sourceMappingURL=client.js.map |
@@ -5,1 +5,2 @@ export * from './client'; | ||
export * from './interfaces/dev.interface'; | ||
export * from './interfaces/ytstatsdata.interface'; |
export declare class Endpoints { | ||
static readonly UserAuth: string; | ||
static readonly DeveloperAuth: string; | ||
static readonly YouTubeStats: string; | ||
} |
@@ -7,3 +7,4 @@ "use strict"; | ||
Endpoints.DeveloperAuth = "/third-party"; | ||
Endpoints.YouTubeStats = "/youtube/statistics"; | ||
exports.Endpoints = Endpoints; | ||
//# sourceMappingURL=endpoints.js.map |
{ | ||
"name": "socialblade", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Library for Social Blade in JavaScript", | ||
@@ -33,3 +33,2 @@ "main": "lib/index.js", | ||
"mocha": "^5.2.0", | ||
"node-fetch": "^2.2.0", | ||
"ts-node": "^7.0.1", | ||
@@ -36,0 +35,0 @@ "typescript": "^3.0.3" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22528
8
26
286