Skip to content

Commit

Permalink
feat: move track types to global namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
devianllert committed Aug 30, 2019
1 parent d3bdc7d commit 7c57476
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 92 deletions.
12 changes: 12 additions & 0 deletions src/@types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-disable */
/// <reference types="node" />

declare namespace NodeJS {
interface ProcessEnv {
readonly NODE_ENV: 'development' | 'production' | 'test';
readonly BOT_TOKEN: string;
readonly PREFIX: string;
readonly EMAIL: string;
readonly PASS: string;
}
}
86 changes: 86 additions & 0 deletions src/@types/tracks.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
interface SearchOptions {
type: string;
}

interface AlbumInfo {
id: number;
storageDir: string;
originalReleaseYear: number;
year: number;
version: string;
type: string;
artists: [];
coverUri: string;
trackCount: number;
genre: string;
available: boolean;
availableForPremiumUsers: boolean;
title: string;
}

interface Artist {
id: number;
cover: Cover;
composer: boolean;
name: string;
various: boolean;
decomposed: [];
}

interface Cover {
type: string;
prefix: string;
uri: string;
}

interface TrackInfo {
id: number;
available: boolean;
availableAsRbt: boolean;
availableForPremiumUsers: boolean;
lyricsAvailable: boolean;
albums: AlbumInfo[];
storageDir: string;
durationMs: number;
explicit: boolean;
title: string;
artists: Artist[];
regions: string[];
}

interface SearchResult {
type: string;
page: number;
perPage: number;
text: string;
searchRequestId: string;
tracks: {
total: number;
perPage: number;
order: number;
results: TrackInfo[];
};
}

interface DownloadInfo {
s: string;
ts: string;
path: string;
host: string;
}

interface PlaylistTrack {
id: number;
track: TrackInfo;
timestamp: string;
recent: boolean;
}

interface Track extends TrackInfo {
trackURL: string;
}

interface DownloadID {
trackID: string;
albumID: string;
}
4 changes: 2 additions & 2 deletions src/core/BotConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ const DefaultBotConfig: BotConfig = {
},

discord: {
token: process.env.BOT_TOKEN as string,
token: process.env.BOT_TOKEN,
log: true,
},

command: {
symbol: process.env.PREFIX as string,
symbol: process.env.PREFIX,
},

queue: {
Expand Down
4 changes: 2 additions & 2 deletions src/core/BotMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export interface MediaItem {
};
name: string;
duration: number;
albums: import('../services/track.service').AlbumInfo[];
artists: import('../services/track.service').Artist[];
albums: AlbumInfo[];
artists: Artist[];
}

export interface MediaType {
Expand Down
88 changes: 0 additions & 88 deletions src/services/track.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,94 +13,6 @@ import logger from '../utils/logger';

dotenv.config();

export interface SearchOptions {
type: string;
}

export interface AlbumInfo {
id: number;
storageDir: string;
originalReleaseYear: number;
year: number;
version: string;
type: string;
artists: [];
coverUri: string;
trackCount: number;
genre: string;
available: boolean;
availableForPremiumUsers: boolean;
title: string;
}

export interface Artist {
id: number;
cover: Cover;
composer: boolean;
name: string;
various: boolean;
decomposed: [];
}

export interface Cover {
type: string;
prefix: string;
uri: string;
}

export interface TrackInfo {
id: number;
available: boolean;
availableAsRbt: boolean;
availableForPremiumUsers: boolean;
lyricsAvailable: boolean;
albums: AlbumInfo[];
storageDir: string;
durationMs: number;
explicit: boolean;
title: string;
artists: Artist[];
regions: string[];
}

export interface SearchResult {
type: string;
page: number;
perPage: number;
text: string;
searchRequestId: string;
tracks: {
total: number;
perPage: number;
order: number;
results: TrackInfo[];
};
}

interface DownloadInfo {
s: string;
ts: string;
path: string;
host: string;
}

interface PlaylistTrack {
id: number;
track: TrackInfo;
timestamp: string;
recent: boolean;
}

export interface Track extends TrackInfo {
trackURL: string;
}

interface DownloadID {
trackID: string;
albumID: string;
}


const downloadInfo = async (storageDir: string): Promise<DownloadInfo> => {
try {
const storageURL = `https://storage.mds.yandex.net/download-info/${storageDir}/2?format=json`;
Expand Down

0 comments on commit 7c57476

Please sign in to comment.