-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: include stream in db, rework blacklisting
- Loading branch information
Gaisberg
authored and
Gaisberg
committed
Jul 26, 2024
1 parent
ade0147
commit 03c6023
Showing
11 changed files
with
100 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import Optional | ||
from RTN import Torrent | ||
from program.db.db import db | ||
import sqlalchemy | ||
from sqlalchemy.orm import Mapped, mapped_column, relationship | ||
|
||
|
||
class Stream(db.Model): | ||
__tablename__ = "Stream" | ||
_id: Mapped[int] = mapped_column(primary_key=True) | ||
infohash: Mapped[str] = mapped_column(sqlalchemy.String, nullable=False) | ||
raw_title: Mapped[str] = mapped_column(sqlalchemy.String, nullable=False) | ||
parsed_title: Mapped[str] = mapped_column(sqlalchemy.String, nullable=False) | ||
rank: Mapped[int] = mapped_column(sqlalchemy.Integer, nullable=False) | ||
lev_ratio: Mapped[float] = mapped_column(sqlalchemy.Float, nullable=False) | ||
blacklisted: Mapped[bool] = mapped_column(sqlalchemy.Boolean, nullable=False) | ||
|
||
parent_id: Mapped[int] = mapped_column(sqlalchemy.ForeignKey("MediaItem._id")) | ||
parent = relationship("MediaItem", back_populates="streams", cascade="all, delete-orphan", single_parent=True) | ||
|
||
def __init__(self, torrent: Torrent): | ||
self.raw_title = torrent.raw_title | ||
self.infohash = torrent.infohash | ||
self.parsed_title = torrent.data.parsed_title | ||
self.rank = torrent.rank | ||
self.lev_ratio = torrent.lev_ratio | ||
self.blacklisted = False | ||
|
||
def __hash__(self): | ||
return self.infohash | ||
|
||
def __eq__(self, other): | ||
return isinstance(other, Stream) and self.infohash == other.infohash | ||
|
Oops, something went wrong.