forked from UltimaHoarder/UltimaScraper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Probably Fixed UltimaHoarder#650 Fixed UltimaHoarder#657 Probably Fixed UltimaHoarder#659 Script no longer uses JSON to store metadata. We'll be using SQLITE from here on out. JSON can be easily corrupted. This also allows us to easily make sure there are no duplicate content stored in the database and folders.
- Loading branch information
1 parent
9bae3df
commit ac185ed
Showing
12 changed files
with
353 additions
and
328 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
import sqlalchemy | ||
from sqlalchemy.orm.session import sessionmaker | ||
from sqlalchemy.ext.declarative.api import declarative_base | ||
from sqlalchemy.orm import scoped_session | ||
|
||
|
||
def create_database_session(metadata_path): | ||
engine = sqlalchemy.create_engine(f'sqlite:///{metadata_path}') | ||
session_factory = sessionmaker(bind=engine) | ||
Session = scoped_session(session_factory) | ||
return Session, engine | ||
|
||
|
||
class type_0(object): | ||
def __init__(self): | ||
base = declarative_base() | ||
self.api_table = base | ||
self.media_table = base | ||
|
||
|
||
def create_api_table(Base, api_type, engine=None): | ||
class api_table(Base): | ||
__tablename__ = api_type.lower() | ||
id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True) | ||
text = sqlalchemy.Column(sqlalchemy.String) | ||
price = sqlalchemy.Column(sqlalchemy.Integer) | ||
paid = sqlalchemy.Column(sqlalchemy.Integer) | ||
created_at = sqlalchemy.Column(sqlalchemy.TIMESTAMP) | ||
return api_table | ||
|
||
|
||
def create_media_table(Base, engine=None): | ||
class media_table(Base): | ||
__tablename__ = "medias" | ||
id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True) | ||
post_id = sqlalchemy.Column(sqlalchemy.Integer) | ||
link = sqlalchemy.Column(sqlalchemy.String) | ||
directory = sqlalchemy.Column(sqlalchemy.String) | ||
filename = sqlalchemy.Column(sqlalchemy.Integer) | ||
size = sqlalchemy.Column(sqlalchemy.Integer, default=None) | ||
media_type = sqlalchemy.Column(sqlalchemy.String) | ||
downloaded = sqlalchemy.Column(sqlalchemy.Integer, default=0) | ||
created_at = sqlalchemy.Column(sqlalchemy.TIMESTAMP) | ||
return media_table |
Oops, something went wrong.