Merge pull request #146 from absidue/misc-improvements
Miscellaneous improvements
This commit is contained in:
commit
76ab060d57
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "play-dl",
|
||||
"version": "1.2.3",
|
||||
"version": "1.2.5",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "play-dl",
|
||||
"version": "1.2.3",
|
||||
"version": "1.2.5",
|
||||
"license": "GPL-3.0",
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.9.4",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "play-dl",
|
||||
"version": "1.2.3",
|
||||
"version": "1.2.5",
|
||||
"description": "YouTube, SoundCloud, Spotify streaming for discord.js bots",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import tls, { TLSSocket } from 'tls';
|
||||
import { URL } from 'url';
|
||||
import tls, { TLSSocket } from 'node:tls';
|
||||
import { URL } from 'node:url';
|
||||
|
||||
interface ProxyOptions extends tls.ConnectionOptions {
|
||||
method: 'GET';
|
||||
@ -69,6 +69,7 @@ export class Proxy {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.socket.setEncoding('utf-8');
|
||||
this.socket.once('error', (err) => reject(err));
|
||||
const parts: string[] = [];
|
||||
this.socket.on('data', (chunk: string) => {
|
||||
if (this.rawHeaders.length === 0) {
|
||||
this.rawHeaders = chunk;
|
||||
@ -76,10 +77,11 @@ export class Proxy {
|
||||
} else {
|
||||
const arr = chunk.split('\r\n');
|
||||
if (arr.length > 1 && arr[0].length < 5) arr.shift();
|
||||
this.body += arr.join('');
|
||||
parts.push(...arr);
|
||||
}
|
||||
});
|
||||
this.socket.on('end', () => {
|
||||
this.body = parts.join('');
|
||||
resolve(this);
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import http, { ClientRequest, IncomingMessage } from 'http';
|
||||
import https, { RequestOptions } from 'https';
|
||||
import { URL } from 'url';
|
||||
import http, { ClientRequest, IncomingMessage } from 'node:http';
|
||||
import https, { RequestOptions } from 'node:https';
|
||||
import { URL } from 'node:url';
|
||||
import { getCookies, setCookie, uploadCookie } from '../YouTube/utils/cookie';
|
||||
import { Proxy } from './classes';
|
||||
|
||||
@ -49,7 +49,6 @@ export function request_stream(req_url: string, options: RequestOpts = { method:
|
||||
export function request(req_url: string, options: RequestOpts = { method: 'GET' }): Promise<string> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
if (!options?.proxies || options.proxies.length === 0) {
|
||||
let data = '';
|
||||
let cookies_added = false;
|
||||
if (options.cookies) {
|
||||
let cook = getCookies();
|
||||
@ -80,9 +79,10 @@ export function request(req_url: string, options: RequestOpts = { method: 'GET'
|
||||
} else if (Number(res.statusCode) > 400) {
|
||||
reject(new Error(`Got ${res.statusCode} from the request`));
|
||||
}
|
||||
const data: string[] = [];
|
||||
res.setEncoding('utf-8');
|
||||
res.on('data', (c) => (data += c));
|
||||
res.on('end', () => resolve(data));
|
||||
res.on('data', (c) => data.push(c));
|
||||
res.on('end', () => resolve(data.join('')));
|
||||
} else {
|
||||
let cookies_added = false;
|
||||
if (options.cookies) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { request, request_stream } from '../Request';
|
||||
import { Readable } from 'stream';
|
||||
import { IncomingMessage } from 'http';
|
||||
import { Readable } from 'node:stream';
|
||||
import { IncomingMessage } from 'node:http';
|
||||
import { StreamType } from '../YouTube/stream';
|
||||
import { Timer } from '../YouTube/classes/LiveStream';
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import fs from 'fs';
|
||||
import fs from 'node:fs';
|
||||
import { StreamType } from '../YouTube/stream';
|
||||
import { request } from '../Request';
|
||||
import { SoundCloudPlaylist, SoundCloudTrack, SoundCloudTrackFormat, Stream } from './classes';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { request } from '../Request';
|
||||
import { SpotifyAlbum, SpotifyPlaylist, SpotifyTrack } from './classes';
|
||||
import fs from 'fs';
|
||||
import fs from 'node:fs';
|
||||
|
||||
let spotifyData: SpotifyDataOptions;
|
||||
if (fs.existsSync('.data/spotify.data')) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Readable } from 'stream';
|
||||
import { IncomingMessage } from 'http';
|
||||
import { Readable } from 'node:stream';
|
||||
import { IncomingMessage } from 'node:http';
|
||||
import { parseAudioFormats, StreamOptions, StreamType } from '../stream';
|
||||
import { ProxyOptions as Proxy, request, request_stream } from '../../Request';
|
||||
import { video_info } from '..';
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { URL } from 'url';
|
||||
import { URL, URLSearchParams } from 'node:url';
|
||||
import { request } from './../../Request';
|
||||
import querystring from 'querystring';
|
||||
|
||||
interface formatOptions {
|
||||
url?: string;
|
||||
@ -164,7 +163,8 @@ export async function format_decipher(formats: formatOptions[], html5player: str
|
||||
formats.forEach((format) => {
|
||||
const cipher = format.signatureCipher || format.cipher;
|
||||
if (cipher) {
|
||||
Object.assign(format, querystring.parse(cipher));
|
||||
const params = Object.fromEntries(new URLSearchParams(cipher));
|
||||
Object.assign(format, params);
|
||||
delete format.signatureCipher;
|
||||
delete format.cipher;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import fs from 'fs';
|
||||
import fs from 'node:fs';
|
||||
|
||||
let youtubeData: youtubeDataOptions;
|
||||
if (fs.existsSync('.data/youtube.data')) {
|
||||
|
||||
@ -31,8 +31,8 @@ interface SearchOptions {
|
||||
};
|
||||
}
|
||||
|
||||
import readline from 'readline';
|
||||
import fs from 'fs';
|
||||
import readline from 'node:readline';
|
||||
import fs from 'node:fs';
|
||||
import {
|
||||
sp_validate,
|
||||
yt_validate,
|
||||
@ -50,7 +50,6 @@ import { SoundCloudTrack } from './SoundCloud/classes';
|
||||
import { yt_search } from './YouTube/search';
|
||||
import { EventEmitter } from 'stream';
|
||||
import { Deezer, dz_search, dz_validate } from './Deezer';
|
||||
|
||||
/**
|
||||
* Main stream Command for streaming through various sources
|
||||
* @param url The video / track url to make stream of
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
"removeComments": false,
|
||||
"alwaysStrict": true,
|
||||
"pretty": true,
|
||||
"target": "es2019",
|
||||
"lib": ["ESNext"],
|
||||
"target": "es2021",
|
||||
"lib": ["ES2021"],
|
||||
"sourceMap": true,
|
||||
"inlineSources": true,
|
||||
"module": "commonjs",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user