Skip to content

Commit

Permalink
Root commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Eltik committed Feb 28, 2023
0 parents commit 2fd38d5
Show file tree
Hide file tree
Showing 21 changed files with 1,023 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CORS_PROXY="https://cors.consumet.stream"
WEB_SERVER_URL="http://localhost:3060"
WEB_SERVER_PORT="3060"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
package-lock.json
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# M3U8-Proxy
Proxy m3u8 files through pure JavaScript.

## Prerequisites
This proxy requires a [CORS proxy](https://github.com/Rob--W/cors-anywhere). You can input it into the `.env` file or in the `API` constructor. NodeJS version 16+ is also required to run.

## Installation
1. Clone the repository.
```bash
git clone https://github.com/Eltik/M3U8-Proxy.git
```
2. Run `npm i`.
3. Run `npm run build`.
4. Run `npm start` or `npm start:pm2` if you want to use [pm2](https://npmjs.com/package/pm2).

You can configure how the proxy works via a `.env` file; it's relatively self-explanatory.
```
CORS_PROXY="https://cors.consumet.stream"
WEB_SERVER_URL="http://localhost:3060"
WEB_SERVER_PORT="3060"
```

## Credit
Inspired by [this](https://github.com/chaycee/M3U8Proxy) repository. I received some help from [chaycee](https://github.com/chaycee) as well.
30 changes: 30 additions & 0 deletions built/API.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// <reference types="node" />
import { Options, Response } from "./libraries/promise-request";
import { ReadStream, WriteStream } from "fs";
export default class API {
sentRequests: SentRequest[];
private userAgent;
config: {
web_server: {
url: string;
port: number;
};
};
constructor(options?: any);
loadConfig(options?: any): void;
fetch(url: string, options?: Options): Promise<Response>;
getCachedRequest(url: string, options?: Options): Response;
stream(url: string, stream: ReadableStream | WritableStream | ReadStream | WriteStream, options?: Options): Promise<unknown>;
wait(time: number): Promise<unknown>;
static wait(time: number): Promise<unknown>;
getRandomInt(max: any): number;
makeId(length: any): string;
stringSearch(string: string, pattern: string): number;
}
interface SentRequest {
url: string;
sent: number;
options: Options;
response: Response;
}
export type { SentRequest };
150 changes: 150 additions & 0 deletions built/API.js

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

1 change: 1 addition & 0 deletions built/API.js.map

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

7 changes: 7 additions & 0 deletions built/libraries/M3U8Proxy.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import API from "../API";
export default class M3U8Proxy extends API {
private url;
private corsProxy;
constructor(url: string);
proxy(headers: any, reply: any): Promise<void>;
}
62 changes: 62 additions & 0 deletions built/libraries/M3U8Proxy.js

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

1 change: 1 addition & 0 deletions built/libraries/M3U8Proxy.js.map

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

42 changes: 42 additions & 0 deletions built/libraries/promise-request.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { AxiosProxyConfig } from "axios";
export default class PromiseRequest {
private url;
private options;
private corsProxy;
constructor(url: string, options: Options);
request(): Promise<Response>;
stream(stream: any): Promise<unknown>;
}
type Options = {
method?: string;
headers?: {
[key: string]: string;
};
body?: string | URLSearchParams | FormData | any;
maxRedirects?: number;
stream?: boolean;
responseType?: string;
proxy?: AxiosProxyConfig | false;
httpsAgent?: any;
useCloudFlare?: boolean;
useCorsProxy?: boolean;
};
interface Response {
request: Request;
status: number;
statusText: string;
url: string;
error: string[];
headers: {
[key: string]: string;
} | Headers;
toString: () => string;
raw: () => any;
text: () => string;
json: () => any;
}
interface Request {
url: string;
options: Options;
}
export type { Options, Response, Request };
Loading

0 comments on commit 2fd38d5

Please sign in to comment.