Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions types/parse-reminder/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Type definitions for parse-reminder 1.3
// Project: https://github.com/bkeepers/parse-reminder#readme
// Definitions by: newt! <https://github.com/definitelytyped>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

export = parseReminder;

declare function parseReminder(reminder: string): ParsedReminder;

interface ParsedReminder {
who: string;
what: string;
when: Date;
}
3 changes: 3 additions & 0 deletions types/parse-reminder/parse-reminder-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import parseReminder from "parse-reminder";

parseReminder('remind me to scream at 9:30pm'); // $ExpectType ParsedReminder
17 changes: 17 additions & 0 deletions types/parse-reminder/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": ["index.d.ts", "parse-reminder-tests.ts"]
}
1 change: 1 addition & 0 deletions types/parse-reminder/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
239 changes: 239 additions & 0 deletions types/soundcloud-scraper/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
// Type definitions for soundcloud-scraper 5.0
// Project: https://soundcloud-scraper.js.org
// Definitions by: newt! <https://github.com/newtykins>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference lib="dom" />
/// <reference types="cheerio" />

import { RequestOptions, IncomingMessage } from 'http';
import { Options as m3u8Options, Stream as m3u8Stream } from 'm3u8stream';

export type Optional<T> = {
[P in keyof T]?: T[P];
};

export interface ClientOptions {
fetchAPIKey?: boolean;
}

export interface CommentAuthor {
name?: string;
username?: string;
url?: string;
}

export interface Comment {
text: string;
createdAt: Date;
author: CommentAuthor;
}

export interface EmbedAuthor {
name: string;
url: string;
}

export interface EmbedProvider {
name: string;
url: string;
}

export interface BaseUser {
name: string;
username: string;
urn: number;
verified: boolean;
}

export interface PlaylistAuthor extends BaseUser {
profile: string;
}

export interface Playlist {
id: number;
title: string;
url: string;
description: string;
thumbnail: string;
author: PlaylistAuthor;
embedURL: string;
embed: Embed;
genre: string;
trackCount: number;
tracks: Song[];
}

export interface PlaylistParseOptions {
fetchEmbed?: boolean;
}

export type SearchResultType = 'track' | 'artist' | 'playlist' | 'unknown';
export type SearchType = 'all' | 'artist' | 'playlist' | 'track';

export interface SearchResult {
index: number;
artist: string;
url: string;
itemName: string;
name: string;
type: SearchResultType;
}

export interface SongAuthor extends BaseUser {
followers: number;
following: number;
avatarURL: string;
url: string;
}

export interface SongStreams {
hls: string;
progressive: string;
}

export interface SongData {
id: string;
title: string;
description: string;
thumbnail: string;
url: string;
duration: number;
playCount: string;
commentsCount: string;
likes: string;
genre: string;
author: SongAuthor;
publishedAt: Date;
embedURL: string;
embed: Embed;
track: Optional<SongStreams>;
trackURL: string;
streamURL: string;
comments: Comment[];
}

export interface UserInfo extends BaseUser {
createdAt: Date;
avatarURL: string;
profile: string;
bannerURL: string;
followers: number;
following: number;
likesCount: number;
tracksCouint: number;
tracks: UserTracks[];
likes: UserLikes[];
}

export interface UserLikesAuthor {
name?: string;
username?: string;
profile?: string;
}

export interface UserLikes {
title: string;
url: string;
publishedAt: Date;
author: UserLikesAuthor;
}

export interface UserTracks {
title: string;
url: string;
publishedAt: Date;
genre: string;
author: string;
duration: number;
}

export interface SongInfoOptions {
fetchEmbed?: boolean;
fetchComments?: boolean;
fetchStreamURL?: boolean;
requestOptions?: RequestInit;
}

export class Client {
constructor(apiKey?: string, options?: ClientOptions);

options: ClientOptions;

apiVersion(force?: boolean): Promise<string>;
createAPIKey(key: string, fetch?: boolean): Promise<void>;
fetchStreamURL(trackURL: string): Promise<string>;
getEmbed(embedURL: string): Promise<Embed>;
getPlaylist(url: string, options?: PlaylistParseOptions): Promise<Playlist>;
getSongInfo(url: string, options?: SongInfoOptions): Promise<Song>;
getUser(username: string): Promise<UserInfo>;
search(query: string, type: SearchType): Promise<SearchResult[]>;
}

export class Downloader {
constructor();

downloadHLS(url: string, options?: m3u8Options): Promise<m3u8Stream>;
downloadProgressive(url: string, options?: RequestOptions): Promise<IncomingMessage>;
}

export class Embed {
constructor(data: object, embedURL: string);

author: EmbedAuthor;
description: string;
height: number;
provider: EmbedProvider;
thumbnailURL: string;
title: string;
type: string;
url: string;
version: number;
visualizer: string;
width: number;

toHTML(): string;
toJSON(): object;
toString(): string;
}

export class Song {
constructor(data: object);

readonly age: number;
author: SongAuthor;
comments: Comment[];
commentsCount: number;
description: string;
duration: number;
embed: Embed;
embedURL: string;
genre: string;
id: string;
likes: number;
playCount: number;
publishedAt: Date;
readonly publishedTimestamp: number;
streams: SongStreams;
streamURL: string;
thumbnail: string;
title: string;
trackURL: string;
url: string;

downloadHLS(options?: m3u8Options): Promise<m3u8Stream>;
downloadProgressive(options?: RequestOptions): Promise<IncomingMessage>;
toJSON(): SongData;
toString(): string;
}

export namespace Util {
function fetchSongStreamURL(songURL: string, clientID: string): Promise<string>;
function keygen(force?: boolean): Promise<string>;
function last(arr: any[]): void;
function loadHTML(html: string): cheerio.Root;
function parseComments(commentSection: string): Comment[];
function parseDuration(duration: string): number;
function parseHTML(url: RequestInfo, options?: RequestInit): Promise<string>;
function request(url: RequestInfo, options?: RequestInit): Promise<Response>;
function validateURL(url: string, type?: SearchType): boolean;
}
6 changes: 6 additions & 0 deletions types/soundcloud-scraper/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"m3u8stream": "^0.8.4"
}
}
49 changes: 49 additions & 0 deletions types/soundcloud-scraper/soundcloud-scraper-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import * as SoundCloud from 'soundcloud-scraper';

const placeholder = 'test';

// Client Tests
const client = new SoundCloud.Client();

client.apiVersion(); // $ExpectType Promise<string>
client.createAPIKey(placeholder); // $ExpectType Promise<void>
client.fetchStreamURL(placeholder); // $ExpectType Promise<string>
client.getEmbed(placeholder); // $ExpectType Promise<Embed>
client.getPlaylist(placeholder); // $ExpectType Promise<Playlist>
client.getSongInfo(placeholder); // $ExpectType Promise<Song>
client.getUser(placeholder); // $ExpectType Promise<UserInfo>
client.search(placeholder, 'all'); // $ExpectType Promise<SearchResult[]>

// Downloader Tests
const downloader = new SoundCloud.Downloader();

downloader.downloadHLS(placeholder); // $ExpectType Promise<Stream>
downloader.downloadProgressive(placeholder); // $ExpectType Promise<IncomingMessage>

// Embed tests
const embed = new SoundCloud.Embed({}, placeholder);

embed.toHTML(); // $ExpectType string
embed.toJSON(); // $ExpectType object
embed.toString(); // $ExpectType string

// Song tests
const song = new SoundCloud.Song({});

song.downloadHLS(); // $ExpectType Promise<Stream>
song.downloadProgressive(); // $ExpectType Promise<IncomingMessage>
song.toJSON(); // $ExpectType SongData
song.toString(); // $ExpectType string

// Utils tests
const utils = SoundCloud.Util;

utils.fetchSongStreamURL(placeholder, placeholder); // $ExpectType Promise<string>
utils.keygen(); // $ExpectType Promise<string>
utils.last([]); // $ExpectType void
utils.loadHTML(placeholder); // $ExpectType Root
utils.parseComments(placeholder); // $ExpectType Comment[]
utils.parseDuration(placeholder); // $ExpectType number
utils.parseHTML(placeholder); // $ExpectType Promise<string>
utils.request(placeholder); // $ExpectType Promise<Response>
utils.validateURL(placeholder); // $ExpectType boolean
24 changes: 24 additions & 0 deletions types/soundcloud-scraper/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": [
"index.d.ts",
"soundcloud-scraper-tests.ts"
]
}
1 change: 1 addition & 0 deletions types/soundcloud-scraper/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }