publish sourcefinder

This commit is contained in:
Lio Young 2021-04-04 16:25:10 +02:00
commit cbcad48852
No known key found for this signature in database
GPG key ID: 789795A11879E169
8 changed files with 327 additions and 0 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
test/
node_modules/
test.ts
build/

2
.npmignore Normal file
View file

@ -0,0 +1,2 @@
node_modules
**.*.log

5
README.md Normal file
View file

@ -0,0 +1,5 @@
# Sourcefinder by [Lio](https://wrwlf.co)
Sourcefinder is a e621 Source finder module for [Thaldrin] v4
[thaldrin]: https://thaldr.in

45
index.ts Normal file
View file

@ -0,0 +1,45 @@
// @ts-nocheck
import pgk from "./package.json"
import defaults from "./src/defaults";
import consts from "./src/consts";
import axios from "axios";
export default class Sourcefinder {
private useragent: string
constructor(useragent?: string) {
this.useragent = useragent ? `${useragent} ${consts.useragent}` : consts.useragent
}
async find(content: string) {
let Links = content.match(consts.md5)
if (!Links) return;
let Sources: string[] = []
for (const Index in Links) {
let ImageURL = Links[Index]
let ImageHash = ImageURL.split(consts.md5)[2]
console.log(this.useragent)
let { data } = await axios.get(`${consts.search_url}${ImageHash}`,
{
headers: {
"User-Agent": this.useragent
}
})
let source: string
switch (data.post.rating) {
case "s":
source = `${consts.enine}${data.post.id}`
break;
default:
source = `${consts.esix}${data.post.id}`
break;
}
Sources.push(source)
}
return Sources
}
}

207
package-lock.json generated Normal file
View file

@ -0,0 +1,207 @@
{
"name": "yiff",
"version": "3.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "yiff",
"version": "3.0.0",
"license": "MIT",
"dependencies": {
"axios": "^0.21.1",
"chalk": "^4.0.0",
"phin": "^3.4.0"
},
"devDependencies": {
"typescript": "^4.2.3"
}
},
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/axios": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
"integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
"dependencies": {
"follow-redirects": "^1.10.0"
}
},
"node_modules/centra": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/centra/-/centra-2.4.2.tgz",
"integrity": "sha512-f1RaP0V1HqVNEXfLfjNBthB2yy3KnSGnPCnOPCFLUk9e/Z4rNJ8nBaJNnghflnp88mi1IT8mfmW+HlMS1/H+bg=="
},
"node_modules/chalk": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
"integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"node_modules/follow-redirects": {
"version": "1.13.3",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz",
"integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA==",
"engines": {
"node": ">=4.0"
}
},
"node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"engines": {
"node": ">=8"
}
},
"node_modules/phin": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/phin/-/phin-3.5.1.tgz",
"integrity": "sha512-jgFO28IaiWAl0xk+zmqVx7neKVokWKU8YTQC5QlB45SZnEE53LH2saqJIcyIV557VX3Gk+TdR4rwWTc3P83DSA==",
"dependencies": {
"centra": "^2.4.2"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/typescript": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.3.tgz",
"integrity": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
}
},
"dependencies": {
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"requires": {
"color-convert": "^2.0.1"
}
},
"axios": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
"integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
"requires": {
"follow-redirects": "^1.10.0"
}
},
"centra": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/centra/-/centra-2.4.2.tgz",
"integrity": "sha512-f1RaP0V1HqVNEXfLfjNBthB2yy3KnSGnPCnOPCFLUk9e/Z4rNJ8nBaJNnghflnp88mi1IT8mfmW+HlMS1/H+bg=="
},
"chalk": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
"integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"follow-redirects": {
"version": "1.13.3",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz",
"integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA=="
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
},
"phin": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/phin/-/phin-3.5.1.tgz",
"integrity": "sha512-jgFO28IaiWAl0xk+zmqVx7neKVokWKU8YTQC5QlB45SZnEE53LH2saqJIcyIV557VX3Gk+TdR4rwWTc3P83DSA==",
"requires": {
"centra": "^2.4.2"
}
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"requires": {
"has-flag": "^4.0.0"
}
},
"typescript": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.3.tgz",
"integrity": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==",
"dev": true
}
}
}

28
package.json Normal file
View file

@ -0,0 +1,28 @@
{
"name": "@thaldrin/sourcefinder",
"version": "1.0.0",
"description": "Module to find e612 sources by their Static1 Link",
"main": "build/index.js",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/thaldrin/sourcefinder.git"
},
"keywords": [
"yiff",
"furry",
"image",
"discord",
"bot",
"e621",
"e926"
],
"author": "hokkqi",
"license": "MIT",
"dependencies": {
"axios": "^0.21.1"
},
"devDependencies": {
"typescript": "^4.2.3"
}
}

13
src/consts.ts Normal file
View file

@ -0,0 +1,13 @@
import pkg from '../package.json'
export default {
md5: new RegExp(
"((?:!)?https?://static[0-9]*.(?:e621|e926).net/data/(?:sample/|preview/|)[0-9a-f]{2}/[0-9a-f]{2}/([0-9a-f]{32}).([0-9a-z]+))",
"igm"),
search_url: "https://e621.net/posts.json?md5=",
enine: 'https://e926.net/posts/',
esix: "https://e926.net/posts/",
version: pkg.version,
useragent: `sourcefinder/v${pkg.version} (t8.pm/sourcefinder);`
}

23
tsconfig.json Normal file
View file

@ -0,0 +1,23 @@
{
"$schema": "http://json.schemastore.org/tsconfig",
"compilerOptions": {
"outDir": "./build",
"allowJs": true,
"target": "esnext",
"baseUrl": "src",
"resolveJsonModule": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"module": "commonjs",
"paths": {},
"typeRoots": ["./node_modules/@types", "./src/"],
"inlineSourceMap": true,
"strict": true,
"declaration": true,
"strictBindCallApply": true,
"strictPropertyInitialization": false
},
"include": ["**/*"],
"exclude": ["node_modules", "build", "out", "tmp", "logs", "test", "old"]
}