File size: 3,376 Bytes
1cac653
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Content {
  id           Int      @id @default(autoincrement())
  tmdbId       String?  @unique @map("tmdb_id")
  title        String
  description  String?  @db.Text
  releaseDate  String?
  
  // Visuales
  imageUrl     String?
  backdropUrl  String?
  trailerUrl   String?  @map("trailer_url")
  
  // Clasificaci贸n y Tipo
  category     String?
  type         String   @default("movie") // "movie" o "tv"
  rating       Float    @default(0.0)
  
  // Relaciones
  seasons      Season[]
  watchlist    Watchlist[] // Relaci贸n con "Mi Lista"

  createdAt    DateTime @default(now())
  updatedAt    DateTime @updatedAt 

  @@index([title]) 
}

// Modelo para "Mi Lista" (Antes Favoritos)
model Watchlist {
  id        Int      @id @default(autoincrement())
  userId    String
  user      User     @relation(fields: [userId], references: [id])
  contentId Int
  content   Content  @relation(fields: [contentId], references: [id])

  createdAt DateTime @default(now())

  @@unique([userId, contentId]) // Evita duplicados en la lista
}

model Season {
  id           Int       @id @default(autoincrement())
  seasonNumber Int
  title        String?
  tmdbId       String?   @unique @map("tmdb_id")
  
  contentId    Int
  content      Content   @relation(fields: [contentId], references: [id], onDelete: Cascade)
  episodes     Episode[]

  createdAt    DateTime  @default(now())
}

model Episode {
  id            Int      @id @default(autoincrement())
  episodeNumber Int
  title         String
  description   String?  @db.Text
  stillPath     String?
  videoUrl      String?
  duration      String?
  
  seasonId      Int
  season        Season   @relation(fields: [seasonId], references: [id], onDelete: Cascade)

  createdAt     DateTime @default(now())
}

enum PlanType {
  basico
  estandar
  premium
}

model User {
  id        String   @id @default(uuid())
  email     String   @unique
  password  String?   @default("123456")
  name      String
  profilePic String? @default("assets/avatars/usuario5.webp")
  createdAt DateTime @default(now())
  plan      PlanType @default(basico)
  isVerified Boolean @default(false)
  pin          String?
  pinExpiresAt DateTime?
  language          String  @default("es")
  parentalPin       String?
  maturityLevel     String  @default("18+")
  subtitleSize      String  @default("medium")
  autoPlay          Boolean @default(true)
  myList        Watchlist[]
}

// Modelo para logs de scraping
model ScrapeLog {
  id          Int      @id @default(autoincrement())
  targetUrl   String   @db.Text
  success     Boolean
  streamUrl   String?  @db.Text
  error       String?  @db.Text
  duration    Int?     // Duraci贸n en milisegundos
  createdAt   DateTime @default(now())
  
  @@index([targetUrl])
  @@index([success])
  @@index([createdAt])
}

// Modelo para enlaces rotos detectados por el scraper
model BrokenLink {
  id        Int      @id @default(autoincrement())
  url       String   @db.Text
  error     String?  @db.Text
  provider  String?
  timestamp DateTime @default(now())
  
  @@index([url])
  @@index([provider])
  @@index([timestamp])
}