aboutsummaryrefslogtreecommitdiff
path: root/multimedia/sickchill/use-older-SQLAlchemy.patch
blob: 4ab716afa245b5023f9d4d6af38404a94179dbdf (plain)
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
diff --git a/sickchill/oldbeard/databases/movie.py b/sickchill/oldbeard/databases/movie.py
index 3598dcc..52000a3 100644
--- a/sickchill/oldbeard/databases/movie.py
+++ b/sickchill/oldbeard/databases/movie.py
@@ -4,45 +4,43 @@ from typing import List
 
 import guessit
 from slugify import slugify
-from sqlalchemy import ForeignKey, JSON
+from sqlalchemy import Boolean, Column, Date, DateTime, ForeignKey, Integer, Interval, JSON, SmallInteger, String
 from sqlalchemy.event import listen
 from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship, sessionmaker
+from sqlalchemy.orm import relationship, sessionmaker
 
 logger = logging.getLogger("sickchill.movie")
 
-
-class Base(DeclarativeBase):
-    """Declarative Base Class"""
-
+Base = declarative_base()
 
 Session = sessionmaker()
 
 
 class Movie(Base):
     __tablename__ = "movie"
-    pk: Mapped[int] = mapped_column(primary_key=True)
-    name: Mapped[str]
-    date: Mapped[datetime.date]
-    year: Mapped[int]
-    status: Mapped[int]
-    paused: Mapped[bool] = mapped_column(default=False)
-    location: Mapped[str]
-    start: Mapped[datetime.timedelta] = mapped_column(default=datetime.timedelta(days=-7))
-    interval: Mapped[datetime.timedelta] = mapped_column(default=datetime.timedelta(days=1))
-    added: Mapped[datetime.datetime] = mapped_column(default=datetime.datetime.now)
-    updated: Mapped[datetime.datetime] = mapped_column(onupdate=datetime.datetime.now)
-    completed: Mapped[datetime.datetime]
-    searched: Mapped[datetime.datetime]
-    slug: Mapped[str]
-
-    language: Mapped[str]
-
-    result_pk: Mapped[int] = mapped_column(ForeignKey("result.pk"))
-    results: Mapped[List["Result"]] = relationship(backref="movie")
-
-    images: Mapped[List["Images"]] = relationship(backref="movie")
-    indexer_data: Mapped[List["IndexerData"]] = relationship(backref="movie")
+
+    pk = Column(Integer, primary_key=True)
+    name = Column(String)
+    date = Column(Date)
+    year = Column(SmallInteger)
+    status = Column(Integer)
+    paused = Column(Boolean, default=False)
+    location = Column(String)
+    start = Column(Interval, default=datetime.timedelta(days=-7))
+    interval = Column(Interval, default=datetime.timedelta(days=1))
+    added = Column(DateTime, default=datetime.datetime.now)
+    updated = Column(DateTime, onupdate=datetime.datetime.now)
+    completed = Column(DateTime)
+    searched = Column(DateTime)
+    slug = Column(String)
+
+    language = Column(String)
+
+    result_pk = Column(Integer, ForeignKey("result.pk"))
+    results: list = relationship("Result", backref="movie")
+
+    images: list = relationship("Images", backref="movie")
+    indexer_data: list = relationship("IndexerData", backref="movie")
 
     def __init__(self, name: str, year: int):
         self.name = name
@@ -134,21 +132,21 @@ listen(Movie.name, "set", Movie.slugify, retval=False)
 
 class Result(Base):
     __tablename__ = "result"
-    pk: Mapped[int] = mapped_column(primary_key=True)
-    name: Mapped[str]
-    title: Mapped[str]
-    url: Mapped[str]
-    size: Mapped[int]
-    year: Mapped[int]
-    provider: Mapped[str]
-    seeders: Mapped[int]
-    leechers: Mapped[int]
-    info_hash: Mapped[str]
-    group: Mapped[str]
-    kind: Mapped[str]
-    guess = mapped_column(JSON)
-    found: Mapped[datetime.datetime] = mapped_column(default=datetime.datetime.now)
-    updated: Mapped[datetime.datetime] = mapped_column(onupdate=datetime.datetime.now)
+    pk = Column(Integer, primary_key=True)
+    name = Column(String)
+    title = Column(String)
+    url = Column(String)
+    size = Column(Integer)
+    year = Column(SmallInteger)
+    provider = Column(String)
+    seeders = Column(Integer)
+    leechers = Column(Integer)
+    info_hash = Column(String)
+    group = Column(String)
+    type = Column(String)
+    guess = Column(JSON)
+    found = Column(DateTime, default=datetime.datetime.now)
+    updated = Column(DateTime, onupdate=datetime.datetime.now)
 
     session = Session()
 
@@ -172,7 +170,7 @@ class Result(Base):
         self.leechers = result["leechers"]
         self.size = result["size"]
         self.year = guess["year"] or movie.year
-        self.kind = provider.provider_type
+        self.type = provider.provider_type
 
         self.provider = provider.get_id()
 
@@ -187,12 +185,12 @@ class Result(Base):
 class Images(Base):
     __tablename__ = "images"
 
-    url: Mapped[str] = mapped_column(primary_key=True)
-    path: Mapped[str]
-    site: Mapped[str]
-    style: Mapped[int]
+    url = Column(String, primary_key=True)
+    path = Column(String)
+    site = Column(String)
+    style = Column(Integer)
 
-    movie_pk: Mapped[int] = mapped_column(ForeignKey("movie.pk"))
+    movie_pk = Column(Integer, ForeignKey("movie.pk"))
 
     def __init__(self, site: str, movie_pk: int, url: str, path: str, style: int):
         self.url = url
@@ -204,13 +202,13 @@ class Images(Base):
 
 class IndexerData(Base):
     __tablename__ = "indexer_data"
-    pk: Mapped[str] = mapped_column(primary_key=True)
-    site: Mapped[str]
-    data = mapped_column(JSON)
+    pk = Column(String, primary_key=True)
+    site = Column(String)
+    data = Column(JSON)
 
-    movie_pk: Mapped[int] = mapped_column(ForeignKey("movie.pk"))
+    movie_pk = Column(Integer, ForeignKey("movie.pk"))
 
-    genres: Mapped[List["Genres"]] = relationship(backref="indexer_data")
+    genres: list = relationship("Genres", backref="indexer_data")
 
     def __repr__(self):
         return f"[{self.__tablename__.replace('_', ' ').title()}] {self.site}: {self.pk} - {self.movie.name}"
@@ -218,5 +216,5 @@ class IndexerData(Base):
 
 class Genres(Base):
     __tablename__ = "genres"
-    pk: Mapped[str] = mapped_column(primary_key=True)
-    indexer_data_pk: Mapped[int] = mapped_column(ForeignKey("indexer_data.pk"))
+    pk = Column(String, primary_key=True)
+    indexer_data_pk = Column(Integer, ForeignKey("indexer_data.pk"))