Ver a proveniência

Initial commit

Add files from pridepack.
master
cometimento
6b59416949
15 ficheiros alterados com 4220 adições e 0 eliminações
  1. +9
    -0
      .eslintrc
  2. +108
    -0
      .gitignore
  3. +7
    -0
      LICENSE
  4. +53
    -0
      package.json
  5. +3
    -0
      pridepack.json
  6. +12
    -0
      src/index.ts
  7. +67
    -0
      src/routes.ts
  8. +7
    -0
      src/server.ts
  9. +15
    -0
      test/index.test.tsx
  10. +21
    -0
      tsconfig.eslint.json
  11. +21
    -0
      tsconfig.json
  12. +1
    -0
      types/index.d.ts
  13. +1
    -0
      types/routes.d.ts
  14. +3
    -0
      types/server.d.ts
  15. +3892
    -0
      yarn.lock

+ 9
- 0
.eslintrc Ver ficheiro

@@ -0,0 +1,9 @@
{
"root": true,
"extends": [
"lxsmnsyc/typescript"
],
"parserOptions": {
"project": "./tsconfig.eslint.json"
}
}

+ 108
- 0
.gitignore Ver ficheiro

@@ -0,0 +1,108 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.production
.env.development

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

.npmrc
.idea/

+ 7
- 0
LICENSE Ver ficheiro

@@ -0,0 +1,7 @@
MIT License Copyright (c) 2023 TheoryOfNekomata <allan.crisostomo@outlook.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 53
- 0
package.json Ver ficheiro

@@ -0,0 +1,53 @@
{
"name": "@modal/webvideo-clip-web-api",
"version": "0.0.0",
"files": [
"dist",
"src"
],
"engines": {
"node": ">=10"
},
"license": "MIT",
"keywords": [
"pridepack"
],
"devDependencies": {
"@types/node": "^18.14.1",
"eslint": "^8.35.0",
"eslint-config-lxsmnsyc": "^0.5.0",
"pridepack": "2.4.2",
"tslib": "^2.5.0",
"typescript": "^4.9.5",
"vitest": "^0.28.1"
},
"dependencies": {
"@modal/webvideo-clip-core": "*",
"fastify": "^4.12.0"
},
"scripts": {
"prepublishOnly": "pridepack clean && pridepack build",
"build": "pridepack build",
"type-check": "pridepack check",
"lint": "pridepack lint",
"clean": "pridepack clean",
"watch": "pridepack watch",
"start": "pridepack start",
"dev": "pridepack dev",
"test": "vitest"
},
"private": false,
"description": "Clip Web videos.",
"repository": {
"url": "https://code.modal.sh/TheoryOfNekomata/webvideo-clip-web-api",
"type": "git"
},
"homepage": "https://code.modal.sh/TheoryOfNekomata/webvideo-clip-web-api",
"bugs": {
"url": "https://code.modal.sh/TheoryOfNekomata/webvideo-clip-web-api/issues"
},
"author": "TheoryOfNekomata <allan.crisostomo@outlook.com>",
"publishConfig": {
"access": "public"
}
}

+ 3
- 0
pridepack.json Ver ficheiro

@@ -0,0 +1,3 @@
{
"target": "es2018"
}

+ 12
- 0
src/index.ts Ver ficheiro

@@ -0,0 +1,12 @@
// SERVER
import SERVER from './server';

import './routes';

SERVER.listen({ port: 8080, host: '0.0.0.0' }, (err, address) => {
if (err) {
SERVER.log.error(err.message);
process.exit(1);
}
SERVER.log.info(`server listening on ${address}`);
});

+ 67
- 0
src/routes.ts Ver ficheiro

@@ -0,0 +1,67 @@
import {
createVideoClipper,
VideoType,
CreateVideoClipperParams,
} from '@modal/webvideo-clip-core';
import { constants } from 'http2';
import SERVER from './server';

SERVER.route({
method: 'POST',
url: '/clip',
handler: async (request, reply) => {
const {
url,
start,
end,
} = request.body as Record<string, unknown>;

const { postprocess = false } = request.query as Record<string, unknown>;

let videoType: string = '';

if (url.startsWith('https://www.youtube.com')) {
videoType = VideoType.YOUTUBE;
}

const videoClipperArgs = {
type: videoType,
url,
start,
end,
downloaderExecutablePath: process.env.YOUTUBE_DOWNLOADER_EXECUTABLE_PATH,
} as CreateVideoClipperParams;
if (postprocess) {
videoClipperArgs.postprocessorExecutablePath = process.env.POSTPROCESSOR_EXECUTABLE_PATH;
}

const clipper = createVideoClipper(videoClipperArgs);

let clipResult: Record<string, unknown>;
clipper.on('success', (result: Record<string, unknown>) => {
clipResult = result;
});

let theError: Error;
clipper.on('error', (error: Error) => {
theError = error;
});

clipper.on('end', () => {
if (theError) {
reply
.status(constants.HTTP_STATUS_INTERNAL_SERVER_ERROR)
.send({
message: theError.message,
});
return;
}

reply
.header('Content-Type', clipResult.type as string)
.send(clipResult.output as Buffer);
});

clipper.process();
},
});

+ 7
- 0
src/server.ts Ver ficheiro

@@ -0,0 +1,7 @@
import fastify from 'fastify';

const SERVER = fastify({
logger: true,
});

export default SERVER;

+ 15
- 0
test/index.test.tsx Ver ficheiro

@@ -0,0 +1,15 @@
import { describe, it, expect } from 'vitest';
import SERVER from '../src/server';
import '../src/routes';

describe('Example', () => {
it('should have the expected content', async () => {
const response = await SERVER
.inject()
.get('/')
.headers({
'Accept': 'application/json',
});
expect(response.statusCode).toBe(200);
});
});

+ 21
- 0
tsconfig.eslint.json Ver ficheiro

@@ -0,0 +1,21 @@
{
"exclude": ["node_modules"],
"include": ["src", "types", "test"],
"compilerOptions": {
"module": "ESNext",
"lib": ["DOM", "ESNext"],
"importHelpers": true,
"declaration": true,
"sourceMap": true,
"rootDir": "./",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"jsx": "react",
"esModuleInterop": true,
"target": "es2018"
}
}

+ 21
- 0
tsconfig.json Ver ficheiro

@@ -0,0 +1,21 @@
{
"exclude": ["node_modules"],
"include": ["src", "types"],
"compilerOptions": {
"module": "ESNext",
"lib": ["ESNext"],
"importHelpers": true,
"declaration": true,
"sourceMap": true,
"rootDir": "./src",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"jsx": "react",
"esModuleInterop": true,
"target": "es2018"
}
}

+ 1
- 0
types/index.d.ts Ver ficheiro

@@ -0,0 +1 @@
import './routes';

+ 1
- 0
types/routes.d.ts Ver ficheiro

@@ -0,0 +1 @@
export {};

+ 3
- 0
types/server.d.ts Ver ficheiro

@@ -0,0 +1,3 @@
/// <reference types="node" />
declare const SERVER: import("fastify").FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault> & PromiseLike<import("fastify").FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>>;
export default SERVER;

+ 3892
- 0
yarn.lock
A apresentação das diferenças no ficheiro foi suprimida por ser demasiado grande
Ver ficheiro


Carregando…
Cancelar
Guardar