Download db.js from mikmc5/ffsio: direct link, hf CLI and curl.
- Browser
- Download file 1.89 kB
-
https://huggingface.co/spaces/mikmc5/ffsio/resolve/main/db.js
- Command line
-
hf download hf://spaces/mikmc5/ffsio/db.js
-
curl -L -o db.js https://huggingface.co/spaces/mikmc5/ffsio/resolve/main/db.js
1.89 kB
| // db.js | |
| import mongoose from 'mongoose'; | |
| const MONGODB_URI = process.env.MONGODB_URI || 'mongodb+srv://greg:DyfaTFCyFzJkYOlK@cluster5.ffkyc.mongodb.net/?retryWrites=true&w=majority&appName=Cluster5'; | |
| mongoose.connect(MONGODB_URI) | |
| .then(() => console.log('📦 Connected to MongoDB')) | |
| .catch(err => console.error('❌ MongoDB connection error:', err)); | |
| // Schema for both movies and series | |
| const ContentSchema = new mongoose.Schema({ | |
| tmdbId: { type: String, required: true }, | |
| type: { type: String, enum: ['movie', 'series'], required: true }, | |
| title: { type: String, required: true }, | |
| // For series episodes | |
| season: Number, | |
| episode: Number, | |
| // Stream data | |
| streams: [{ | |
| hash: { type: String, required: true }, // Store hash instead of full magnet | |
| filename: String, | |
| websiteTitle: String, | |
| quality: String, | |
| size: String, | |
| source: String, // Added source field | |
| // Cache status by service name (true/false) | |
| cachedOn: { | |
| debridlink: { type: Boolean, default: false }, | |
| premiumize: { type: Boolean, default: false }, | |
| torbox: { type: Boolean, default: false } | |
| }, | |
| lastChecked: { type: Date, default: Date.now }, | |
| addedAt: { type: Date, default: Date.now } | |
| }], | |
| lastUpdated: { type: Date, default: Date.now } | |
| }, { | |
| timestamps: true | |
| }); | |
| // Compound unique index for content identification | |
| ContentSchema.index({ | |
| tmdbId: 1, | |
| type: 1, | |
| season: 1, | |
| episode: 1 | |
| }, { | |
| unique: true, | |
| partialFilterExpression: { type: 'series' } | |
| }); | |
| ContentSchema.index({ | |
| tmdbId: 1, | |
| type: 1 | |
| }, { | |
| unique: true, | |
| partialFilterExpression: { type: 'movie' } | |
| }); | |
| // Index for hash lookups | |
| ContentSchema.index({ 'streams.hash': 1 }); | |
| const Content = mongoose.model('Content', ContentSchema); | |
| export default Content; |