ygg-eu-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 fredodiable
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # Ygg-EU SDK
2
+
3
+ [![npm version](https://img.shields.io/npm/v/ygg-eu-sdk.svg)](https://www.npmjs.com/package/ygg-eu-sdk)
4
+ [![Build Status](https://github.com/fredodiable/ygg-eu-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/fredodiable/ygg-eu-sdk/actions)
5
+ [![Dependencies](https://img.shields.io/badge/dependencies-0-success)](https://www.npmjs.com/package/ygg-eu-sdk)
6
+ [![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
7
+
8
+ Un SDK TypeScript pour l'API non officielle [yggapi.eu](https://yggapi.eu/).
9
+
10
+ ## ✨ Points forts
11
+
12
+ - 🪶 **Ultra léger** : Empreinte minimale sur votre projet.
13
+ - 🛡️ **Zéro Dépendance** : Utilise l'API `fetch` native.
14
+ - 💪 **Type-Safe** : Développé en TypeScript pour une autocomplétion parfaite.
15
+ - 🧪 **Fiable** : Couverture complète par tests unitaires et d'intégration.
16
+
17
+ ## 🚀 Installation
18
+
19
+ ```bash
20
+ npm install ygg-eu-sdk
21
+ ```
22
+
23
+ ## 📖 Exemples d'utilisation
24
+
25
+ ### Initialisation
26
+
27
+ #### En TypeScript (ESM)
28
+
29
+ ```typescript
30
+ import { YggEuClient } from 'ygg-eu-sdk';
31
+
32
+ const client = new YggEuClient({
33
+ //Paramètres optionnels
34
+ passkey: 'VOTRE_PASSKEY', // Requis uniquement pour le téléchargement
35
+ timeout: 5000, // Délai d'expiration en ms (par défaut 10s)
36
+ });
37
+ ```
38
+
39
+ #### En JavaScript (CommonJS)
40
+
41
+ ```javascript
42
+ const { YggEuClient } = require('ygg-eu-sdk');
43
+
44
+ const client = new YggEuClient({
45
+ // ...
46
+ });
47
+ ```
48
+
49
+ ### 🔍 Rechercher un torrent
50
+
51
+ #### Recherche minimal
52
+
53
+ ```typescript
54
+ const results = await client.torrents.search({
55
+ q: 'Inception',
56
+ });
57
+ ```
58
+
59
+ #### Recherche détaillée
60
+
61
+ ```typescript
62
+ import { YggCategory } from 'ygg-eu-sdk';
63
+
64
+ const results = await client.torrents.search({
65
+ q: 'Altered Carbon',
66
+ category_id: YggCategory.VIDEOS_SERIE_TV,
67
+ season: 1,
68
+ per_page: 25,
69
+ });
70
+ ```
71
+
72
+ ### 📝 Obtenir les détails
73
+
74
+ ```typescript
75
+ const details = await client.torrents.getDetail(123);
76
+ console.log(details.title);
77
+ ```
78
+
79
+ ### ⬇️ Télécharger un fichier .torrent
80
+
81
+ ```typescript
82
+ import { writeFileSync } from 'fs';
83
+
84
+ const torrentBuffer = await client.torrents.download(123);
85
+ writeFileSync('test.torrent', Buffer.from(torrentBuffer));
86
+ ```
87
+
88
+ ## ⚖️ Licence
89
+
90
+ Ce projet est sous licence **MIT**. Vous êtes libre de l'utiliser, de le modifier et de le distribuer, même à des fins commerciales. Voir le fichier [LICENSE](https://github.com/fredodiable/ygg-eu-sdk/blob/main/LICENSE) pour plus de détails.
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var n=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var m=(o,r)=>{for(var e in r)n(o,e,{get:r[e],enumerable:!0})},p=(o,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of h(r))!w.call(o,t)&&t!==e&&n(o,t,{get:()=>r[t],enumerable:!(a=l(r,t))||a.enumerable});return o};var d=o=>p(n({},"__esModule",{value:!0}),o);var f={};m(f,{YggEuClient:()=>i});module.exports=d(f);var i=class{baseUrl;passkey;timeout;constructor(r={}){this.baseUrl=r.baseUrl||"https://yggapi.eu",this.passkey=r.passkey,this.timeout=r.timeout||1e4}async request(r,e={}){let a=new AbortController,t=setTimeout(()=>a.abort(),this.timeout),u={Accept:"application/json","User-Agent":"ygg-eu-sdk/1.0.0",...e.headers};try{let s=await fetch(`${this.baseUrl}${r}`,{...e,headers:u,signal:a.signal});if(clearTimeout(t),!s.ok){let c=await s.json().catch(()=>({}));throw new Error(`YggApi ${s.status}: ${s.statusText}`,{cause:{status:s.status,detail:c}})}return await s.json()}catch(s){throw clearTimeout(t),s instanceof Error?s.name==="AbortError"?new Error("Request timeout"):s:new Error("An unknown error occurred",{cause:s})}}torrents={search:r=>{let e=new URLSearchParams;return Object.entries(r).forEach(([a,t])=>{t!==void 0&&e.append(a,t.toString())}),this.request(`/torrents?${e.toString()}`)},getDetails:r=>this.request(`/torrent/${r}`),download:async r=>{if(!this.passkey)throw new Error("Passkey is required for download");let e=await fetch(`${this.baseUrl}/torrent/${r}/download?passkey=${this.passkey}`,{headers:{"User-Agent":"ygg-eu-sdk/1.0.0"}});if(!e.ok)throw new Error(`Download failed: ${e.statusText}`);return await e.arrayBuffer()}}};0&&(module.exports={YggEuClient});
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Catégories officielles YGG
3
+ */
4
+ declare enum YggCategory {
5
+ ALL = 0,
6
+ AUDIO = 2139,
7
+ AUDIO_KARAOKE = 2147,
8
+ AUDIO_MUSIQUE = 2148,
9
+ AUDIO_SAMPLES = 2149,
10
+ AUDIO_PODCAST_RADIO = 2150,
11
+ EBOOK = 2140,
12
+ EBOOK_AUDIO = 2151,
13
+ EBOOK_BD = 2152,
14
+ EBOOK_COMICS = 2153,
15
+ EBOOK_LIVRES = 2154,
16
+ EBOOK_MANGA = 2155,
17
+ EBOOK_PRESSE = 2156,
18
+ JEUX_VIDEO = 2142,
19
+ JEUX_LINUX = 2159,
20
+ JEUX_MACOS = 2160,
21
+ JEUX_WINDOWS = 2161,
22
+ JEUX_NINTENDO = 2163,
23
+ JEUX_SONY = 2164,
24
+ JEUX_SMARTPHONE = 2165,
25
+ JEUX_TABLETTE = 2166,
26
+ JEUX_AUTRE = 2167,
27
+ APPLICATIONS = 2144,
28
+ APPLICATIONS_LINUX = 2168,
29
+ APPLICATIONS_MACOS = 2169,
30
+ APPLICATIONS_WINDOWS = 2170,
31
+ APPLICATIONS_SMARTPHONE = 2171,
32
+ APPLICATIONS_TABLETTE = 2172,
33
+ APPLICATIONS_FORMATION = 2177,
34
+ VIDEOS = 2145,
35
+ VIDEOS_ANIMATION = 2178,
36
+ VIDEOS_ANIMATION_SERIE = 2179,
37
+ VIDEOS_CONCERT = 2180,
38
+ VIDEOS_DOCUMENTAIRE = 2181,
39
+ VIDEOS_EMISSION_TV = 2182,
40
+ VIDEOS_FILM = 2183,
41
+ VIDEOS_SERIE_TV = 2184,
42
+ VIDEOS_SPECTACLE = 2185,
43
+ VIDEOS_SPORT = 2186,
44
+ VIDEOS_CLIP_VIDEO = 2187,
45
+ GPS = 2143,
46
+ GPS_APPLICATIONS = 2173,
47
+ GPS_CARTES = 2174,
48
+ GPS_DIVERS = 2175,
49
+ IMPRIMANTE_3D = 2200,
50
+ IMPRIMANTE_3D_OBJETS = 2201,
51
+ IMPRIMANTE_3D_PERSONNAGES = 2202,
52
+ NULLED = 2210,
53
+ NULLED_WORDPRESS = 2211,
54
+ NULLED_SCRIPTS_PHP_CMS = 2212,
55
+ NULLED_MOBILE = 2213,
56
+ NULLED_DIVERS = 2214
57
+ }
58
+ interface SearchParams {
59
+ page?: number;
60
+ q?: string;
61
+ category_id?: YggCategory | number;
62
+ order_by?: 'uploaded_at' | 'seeders' | 'downloads';
63
+ per_page?: 25 | 50 | 100;
64
+ season?: number;
65
+ episode?: number;
66
+ type?: 'movie' | 'tv';
67
+ tmdb_id?: number;
68
+ }
69
+ interface TorrentResult {
70
+ id: number;
71
+ title: string;
72
+ seeders: number;
73
+ leechers: number;
74
+ downloads: number | undefined;
75
+ size: number;
76
+ category_id: number;
77
+ uploaded_at: string;
78
+ link: string;
79
+ }
80
+ interface TorrentDetails extends TorrentResult {
81
+ description: string | undefined;
82
+ hash: string | undefined;
83
+ updated_at: string;
84
+ type: string | undefined;
85
+ tmdb_id: number | undefined;
86
+ }
87
+ interface ClientConfig {
88
+ passkey?: string;
89
+ baseUrl?: string;
90
+ timeout?: number;
91
+ }
92
+
93
+ declare class YggEuClient {
94
+ private readonly baseUrl;
95
+ private readonly passkey?;
96
+ private readonly timeout;
97
+ constructor(config?: ClientConfig);
98
+ private request;
99
+ torrents: {
100
+ search: (params: SearchParams) => Promise<TorrentResult[]>;
101
+ getDetails: (id: number) => Promise<TorrentDetails>;
102
+ download: (id: number) => Promise<ArrayBuffer>;
103
+ };
104
+ }
105
+
106
+ export { YggEuClient };
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Catégories officielles YGG
3
+ */
4
+ declare enum YggCategory {
5
+ ALL = 0,
6
+ AUDIO = 2139,
7
+ AUDIO_KARAOKE = 2147,
8
+ AUDIO_MUSIQUE = 2148,
9
+ AUDIO_SAMPLES = 2149,
10
+ AUDIO_PODCAST_RADIO = 2150,
11
+ EBOOK = 2140,
12
+ EBOOK_AUDIO = 2151,
13
+ EBOOK_BD = 2152,
14
+ EBOOK_COMICS = 2153,
15
+ EBOOK_LIVRES = 2154,
16
+ EBOOK_MANGA = 2155,
17
+ EBOOK_PRESSE = 2156,
18
+ JEUX_VIDEO = 2142,
19
+ JEUX_LINUX = 2159,
20
+ JEUX_MACOS = 2160,
21
+ JEUX_WINDOWS = 2161,
22
+ JEUX_NINTENDO = 2163,
23
+ JEUX_SONY = 2164,
24
+ JEUX_SMARTPHONE = 2165,
25
+ JEUX_TABLETTE = 2166,
26
+ JEUX_AUTRE = 2167,
27
+ APPLICATIONS = 2144,
28
+ APPLICATIONS_LINUX = 2168,
29
+ APPLICATIONS_MACOS = 2169,
30
+ APPLICATIONS_WINDOWS = 2170,
31
+ APPLICATIONS_SMARTPHONE = 2171,
32
+ APPLICATIONS_TABLETTE = 2172,
33
+ APPLICATIONS_FORMATION = 2177,
34
+ VIDEOS = 2145,
35
+ VIDEOS_ANIMATION = 2178,
36
+ VIDEOS_ANIMATION_SERIE = 2179,
37
+ VIDEOS_CONCERT = 2180,
38
+ VIDEOS_DOCUMENTAIRE = 2181,
39
+ VIDEOS_EMISSION_TV = 2182,
40
+ VIDEOS_FILM = 2183,
41
+ VIDEOS_SERIE_TV = 2184,
42
+ VIDEOS_SPECTACLE = 2185,
43
+ VIDEOS_SPORT = 2186,
44
+ VIDEOS_CLIP_VIDEO = 2187,
45
+ GPS = 2143,
46
+ GPS_APPLICATIONS = 2173,
47
+ GPS_CARTES = 2174,
48
+ GPS_DIVERS = 2175,
49
+ IMPRIMANTE_3D = 2200,
50
+ IMPRIMANTE_3D_OBJETS = 2201,
51
+ IMPRIMANTE_3D_PERSONNAGES = 2202,
52
+ NULLED = 2210,
53
+ NULLED_WORDPRESS = 2211,
54
+ NULLED_SCRIPTS_PHP_CMS = 2212,
55
+ NULLED_MOBILE = 2213,
56
+ NULLED_DIVERS = 2214
57
+ }
58
+ interface SearchParams {
59
+ page?: number;
60
+ q?: string;
61
+ category_id?: YggCategory | number;
62
+ order_by?: 'uploaded_at' | 'seeders' | 'downloads';
63
+ per_page?: 25 | 50 | 100;
64
+ season?: number;
65
+ episode?: number;
66
+ type?: 'movie' | 'tv';
67
+ tmdb_id?: number;
68
+ }
69
+ interface TorrentResult {
70
+ id: number;
71
+ title: string;
72
+ seeders: number;
73
+ leechers: number;
74
+ downloads: number | undefined;
75
+ size: number;
76
+ category_id: number;
77
+ uploaded_at: string;
78
+ link: string;
79
+ }
80
+ interface TorrentDetails extends TorrentResult {
81
+ description: string | undefined;
82
+ hash: string | undefined;
83
+ updated_at: string;
84
+ type: string | undefined;
85
+ tmdb_id: number | undefined;
86
+ }
87
+ interface ClientConfig {
88
+ passkey?: string;
89
+ baseUrl?: string;
90
+ timeout?: number;
91
+ }
92
+
93
+ declare class YggEuClient {
94
+ private readonly baseUrl;
95
+ private readonly passkey?;
96
+ private readonly timeout;
97
+ constructor(config?: ClientConfig);
98
+ private request;
99
+ torrents: {
100
+ search: (params: SearchParams) => Promise<TorrentResult[]>;
101
+ getDetails: (id: number) => Promise<TorrentDetails>;
102
+ download: (id: number) => Promise<ArrayBuffer>;
103
+ };
104
+ }
105
+
106
+ export { YggEuClient };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ var a=class{baseUrl;passkey;timeout;constructor(r={}){this.baseUrl=r.baseUrl||"https://yggapi.eu",this.passkey=r.passkey,this.timeout=r.timeout||1e4}async request(r,t={}){let o=new AbortController,s=setTimeout(()=>o.abort(),this.timeout),n={Accept:"application/json","User-Agent":"ygg-eu-sdk/1.0.0",...t.headers};try{let e=await fetch(`${this.baseUrl}${r}`,{...t,headers:n,signal:o.signal});if(clearTimeout(s),!e.ok){let i=await e.json().catch(()=>({}));throw new Error(`YggApi ${e.status}: ${e.statusText}`,{cause:{status:e.status,detail:i}})}return await e.json()}catch(e){throw clearTimeout(s),e instanceof Error?e.name==="AbortError"?new Error("Request timeout"):e:new Error("An unknown error occurred",{cause:e})}}torrents={search:r=>{let t=new URLSearchParams;return Object.entries(r).forEach(([o,s])=>{s!==void 0&&t.append(o,s.toString())}),this.request(`/torrents?${t.toString()}`)},getDetails:r=>this.request(`/torrent/${r}`),download:async r=>{if(!this.passkey)throw new Error("Passkey is required for download");let t=await fetch(`${this.baseUrl}/torrent/${r}/download?passkey=${this.passkey}`,{headers:{"User-Agent":"ygg-eu-sdk/1.0.0"}});if(!t.ok)throw new Error(`Download failed: ${t.statusText}`);return await t.arrayBuffer()}}};export{a as YggEuClient};
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "ygg-eu-sdk",
3
+ "version": "1.0.0",
4
+ "description": "SDK TypeScript léger et zéro-dépendance pour yggapi.eu",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsup",
21
+ "dev": "tsup --watch",
22
+ "format": "prettier --check \"{src,tests}/**/*.ts\"",
23
+ "format:fix": "prettier --write \"{src,tests}/**/*.ts\"",
24
+ "lint": "eslint \"{src,tests}/**/*.ts\"",
25
+ "lint:fix": "eslint \"{src,tests}/**/*.ts\" --fix",
26
+ "test": "vitest run --project=unit",
27
+ "test:integration": "vitest run --project=integration",
28
+ "test:all": "vitest run",
29
+ "prepublishOnly": "npm run format && npm run lint && npm run test && npm run build"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/fredodiable/ygg-eu-sdk.git"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/fredodiable/ygg-eu-sdk/issues"
37
+ },
38
+ "homepage": "https://github.com/fredodiable/ygg-eu-sdk#readme",
39
+ "keywords": [
40
+ "ygg",
41
+ "api",
42
+ "sdk",
43
+ "typescript",
44
+ "torrent",
45
+ "yggapi"
46
+ ],
47
+ "author": "fredodiable",
48
+ "license": "MIT",
49
+ "engines": {
50
+ "node": ">=18.0.0"
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^20.0.0",
54
+ "@typescript-eslint/eslint-plugin": "^8.52.0",
55
+ "@typescript-eslint/parser": "^8.52.0",
56
+ "eslint": "^9.39.2",
57
+ "eslint-config-prettier": "^10.1.8",
58
+ "eslint-plugin-import": "^2.32.0",
59
+ "prettier": "^3.0.0",
60
+ "tsup": "^8.0.0",
61
+ "typescript": "^5.0.0",
62
+ "vitest": "^4.0.16"
63
+ }
64
+ }