コード例 #1
0
ファイル: imdb_list.py プロジェクト: diogosena/Flexget
from sqlalchemy.orm import relation
from sqlalchemy.schema import ForeignKey

from flexget import plugin, db_schema
from flexget.entry import Entry
from flexget.event import event
from flexget.plugin import PluginError
from flexget.manager import Session
from flexget.utils.database import json_synonym
from flexget.utils.requests import Session as RequestSession, TimedLimiter
from flexget.utils.soup import get_soup

log = logging.getLogger('imdb_list')
IMMUTABLE_LISTS = ['ratings', 'checkins']

Base = db_schema.versioned_base('imdb_list', 0)

MOVIE_TYPES = ['documentary', 'tvmovie', 'video', 'short', 'movie']
SERIES_TYPES = ['tvseries', 'tvepisode', 'tvminiseries']
OTHER_TYPES = ['videogame']


class IMDBListUser(Base):
    __tablename__ = "imdb_list_user"

    user_id = Column(String, primary_key=True)
    user_name = Column(Unicode)
    _cookies = Column('cookies', Unicode)
    cookies = json_synonym('_cookies')

    lists = relation('IMDBListList',
コード例 #2
0
ファイル: movie_list.py プロジェクト: AlinaKay/Flexget
from sqlalchemy import Column, Unicode, Integer, ForeignKey, func, DateTime
from sqlalchemy.orm import relationship
from sqlalchemy.sql.elements import and_

from flexget import plugin
from flexget.manager import Session
from flexget.db_schema import versioned_base, with_session
from flexget.entry import Entry
from flexget.event import event
from flexget.plugin import get_plugin_by_name
from flexget.plugins.parsers.parser_common import normalize_name, remove_dirt
from flexget.utils.tools import split_title_year

log = logging.getLogger('movie_list')
Base = versioned_base('movie_list', 0)


class MovieListBase(object):
    """
    Class that contains helper methods for movie list as well as plugins that use it,
    such as API and CLI.
    """

    @property
    def supported_ids(self):
        # Return a list of supported series identifier as registered via their plugins
        ids = []
        for p in plugin.get_plugins(group='movie_metainfo'):
            ids.append(p.instance.movie_identifier)
        return ids
コード例 #3
0
ファイル: api_t411.py プロジェクト: ghyster/Flexget
from flexget.plugin import PluginError
from flexget.utils import qualities
from flexget.utils.database import with_session
from requests.auth import AuthBase

from sqlalchemy import (Table, Column, Integer, String, ForeignKey, DateTime, Boolean)
from sqlalchemy.orm import relation, backref
from flexget import db_schema
from flexget.utils.requests import Session
from sqlalchemy.orm.exc import NoResultFound

log = logging.getLogger('t411_api')

# region ORM definitions
SCHEMA_VER = 0
Base = db_schema.versioned_base('t411', SCHEMA_VER)
category_term_types = Table('category_term_types', Base.metadata,
                            Column('category_id', Integer, ForeignKey('categories.id')),
                            Column('term_type_id', Integer, ForeignKey('term_types.id')))
Base.register_table(category_term_types)

torrent_terms = Table('torrent_terms', Base.metadata,
                      Column('torrent_id', Integer, ForeignKey('torrent.id')),
                      Column('term_id', Integer, ForeignKey('term.id')))
Base.register_table(torrent_terms)


@db_schema.upgrade('t411')
def upgrade(ver, session):
    return SCHEMA_VER
コード例 #4
0
ファイル: myepisodes.py プロジェクト: awesome-python/Flexget
import http.cookiejar

from sqlalchemy import Column, Integer, String, DateTime

from flexget import db_schema, plugin
from flexget.event import event

try:
    from flexget.plugins.api_tvdb import lookup_series
except ImportError:
    raise plugin.DependencyError(issued_by='myepisodes', missing='api_tvdb',
                                 message='myepisodes requires the `api_tvdb` plugin')


log = logging.getLogger('myepisodes')
Base = db_schema.versioned_base('myepisodes', 0)


class MyEpisodesInfo(Base):
    __tablename__ = 'myepisodes'

    id = Column(Integer, primary_key=True)
    series_name = Column(String, unique=True)
    myepisodes_id = Column(Integer, unique=True)
    updated = Column(DateTime)

    def __init__(self, series_name, myepisodes_id):
        self.series_name = series_name
        self.myepisodes_id = myepisodes_id
        self.updated = datetime.now()
コード例 #5
0
ファイル: torrent411.py プロジェクト: JorisDeRieck/Flexget
from flexget.utils.soup import get_soup
from flexget.utils.search import torrent_availability, normalize_unicode

from flexget.manager import Session
from flexget.db_schema import versioned_base
from requests.auth import AuthBase

from datetime import datetime, timedelta

from sqlalchemy.types import TypeDecorator, VARCHAR
from sqlalchemy import Column, Unicode, Integer, DateTime

__author__ = "blAStcodeM"

log = logging.getLogger("torrent411")
Base = versioned_base("torrent411", 0)

CATEGORIES = {
    "Animation": 455,
    "Animation-Serie": 637,
    "Concert": 633,
    "Documentaire": 634,
    "Emission-TV": 639,
    "Film": 631,
    "Serie-TV": 433,
    "Series": 1,
    "Spectacle": 635,
    "Sport": 636,
    "Video-clips": 402,
}
コード例 #6
0
ファイル: subtitle_list.py プロジェクト: Flexget/Flexget
from datetime import datetime, date, time

from sqlalchemy import Column, Unicode, Integer, ForeignKey, func, DateTime, and_
from sqlalchemy.orm import relationship
from babelfish import Language

from flexget import plugin
from flexget.manager import Session
from flexget.db_schema import versioned_base, with_session
from flexget.entry import Entry
from flexget.event import event
from flexget.utils.tools import parse_timedelta
from flexget.utils.template import RenderError

log = logging.getLogger('subtitle_list')
Base = versioned_base('subtitle_list', 1)

#: Video extensions stolen from https://github.com/Diaoul/subliminal/blob/master/subliminal/video.py
VIDEO_EXTENSIONS = (
    '.3g2',
    '.3gp',
    '.3gp2',
    '.3gpp',
    '.60d',
    '.ajp',
    '.asf',
    '.asx',
    '.avchd',
    '.avi',
    '.bik',
    '.bix',
コード例 #7
0
ファイル: plugin_rutracker.py プロジェクト: andir/Flexget
from flexget.plugin import PluginError
from flexget.manager import Session

from sqlalchemy import Column, Unicode, Integer, DateTime
from sqlalchemy.types import TypeDecorator, VARCHAR

from requests import post
from requests.auth import AuthBase
from requests.cookies import cookiejar_from_dict
from requests.utils import dict_from_cookiejar


__author__ = 'asm0dey'

log = logging.getLogger('rutracker_auth')
Base = versioned_base('rutracker_auth', 0)


class JSONEncodedDict(TypeDecorator):

    """Represents an immutable structure as a json-encoded string.

    Usage:

        JSONEncodedDict(255)

    """

    impl = VARCHAR

    def process_bind_param(self, value, dialect):
コード例 #8
0
from builtins import *  # noqa pylint: disable=unused-import, redefined-builtin
from datetime import datetime
from sqlalchemy import Column, String, Unicode, DateTime, Integer
import logging

from flexget import db_schema, plugin
from flexget.entry import Entry
from flexget.utils.database import quality_property
from flexget.db_schema import Session
from flexget.event import event
from flexget.utils import qualities
from flexget.utils.tools import parse_timedelta, group_entries

log = logging.getLogger('upgrade')

Base = db_schema.versioned_base('upgrade', 0)

entry_actions = {
    'accept': Entry.accept,
    'reject': Entry.reject,
    'fail': Entry.fail
}


class EntryUpgrade(Base):
    __tablename__ = 'upgrade'

    id = Column(Unicode, primary_key=True, index=True)
    title = Column(Unicode)
    _quality = Column('quality', String)
    quality = quality_property('_quality')
コード例 #9
0
from flexget.utils.tools import urlopener
from flexget.utils.database import pipe_list_synonym, with_session
from flexget.utils.sqlalchemy_utils import drop_tables, table_columns
from flexget.utils.cached_input import cached
from flexget.entry import Entry

try:
    from flexget.plugins.api_tvdb import lookup_series
except ImportError:
    raise DependencyError(
        issued_by='thetvdb_favorites',
        missing='api_tvdb',
        message='thetvdb_lookup requires the `api_tvdb` plugin')

log = logging.getLogger('thetvdb_favorites')
Base = db_schema.versioned_base('thetvdb_favorites', 0)


@db_schema.upgrade('thetvdb_favorites')
def upgrade(ver, session):
    if ver is None:
        columns = table_columns('thetvdb_favorites', session)
        if not 'series_ids' in columns:
            # Drop the old table
            log.info('Dropping old version of thetvdb_favorites table from db')
            drop_tables(['thetvdb_favorites'], session)
            # Create new table from the current model
            Base.metadata.create_all(bind=session.bind)
        ver = 0
    return ver
コード例 #10
0
ファイル: myepisodes.py プロジェクト: pospqsjac/Flexget
import logging
import re
from datetime import datetime

from sqlalchemy import Column, DateTime, Integer, String

from flexget import plugin
from flexget.db_schema import versioned_base
from flexget.event import event
from flexget.utils import requests

log = logging.getLogger('myepisodes')
Base = versioned_base('myepisodes', 0)


class MyEpisodesInfo(Base):
    __tablename__ = 'myepisodes'

    id = Column(Integer, primary_key=True)
    series_name = Column(String, unique=True)
    myepisodes_id = Column(Integer, unique=True)
    updated = Column(DateTime)

    def __init__(self, series_name, myepisodes_id):
        self.series_name = series_name
        self.myepisodes_id = myepisodes_id
        self.updated = datetime.now()

    def __repr__(self):
        return '<MyEpisodesInfo(series_name=%s, myepisodes_id=%s)>' % (
            self.series_name,
コード例 #11
0
from __future__ import unicode_literals, division, absolute_import
from builtins import *

import logging
from datetime import datetime

from sqlalchemy import Column, Integer, String, Unicode, DateTime

from flexget import db_schema
from flexget.plugin import priority
from flexget.utils.sqlalchemy_utils import table_add_column

log = logging.getLogger('queue')
Base = db_schema.versioned_base('queue', 2)


@db_schema.upgrade('queue')
def upgrade(ver, session):
    if False:  # ver == 0: disable this, since we don't have a remove column function
        table_add_column('queue', 'last_emit', DateTime, session)
        ver = 1
    if ver < 2:
        # We don't have a remove column for 'last_emit', do nothing
        ver = 2
    return ver


class QueuedItem(Base):
    __tablename__ = 'queue'
    id = Column(Integer, primary_key=True)
    title = Column(Unicode)
コード例 #12
0
ファイル: api_bluray.py プロジェクト: yuyulklk/Flexget
import time

from sqlalchemy import Table, Column, Integer, Float, Unicode, DateTime, Date, func
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.schema import ForeignKey
from sqlalchemy.orm import relation
from dateutil.parser import parse as dateutil_parse

from flexget import db_schema, plugin
from flexget.utils.soup import get_soup
from flexget.event import event
from flexget.utils import requests
from flexget.utils.database import year_property

log = logging.getLogger('api_bluray')
Base = db_schema.versioned_base('api_bluray', 0)

# association tables
genres_table = Table(
    'bluray_movie_genres',
    Base.metadata,
    Column('movie_id', Integer, ForeignKey('bluray_movies.id')),
    Column('genre_name', Integer, ForeignKey('bluray_genres.name')),
)
Base.register_table(genres_table)

BASE_URL = 'http://m.blu-ray.com/'


def bluray_request(endpoint, **params):
    full_url = BASE_URL + endpoint
コード例 #13
0
import logging
import pickle
from collections import MutableMapping, defaultdict
from datetime import datetime

from sqlalchemy import Column, Integer, String, DateTime, Unicode, select, Index

from flexget import db_schema
from flexget.event import event
from flexget.manager import Session
from flexget.utils import json
from flexget.utils.database import json_synonym
from flexget.utils.sqlalchemy_utils import table_schema, create_index, table_add_column

log = logging.getLogger('util.simple_persistence')
Base = db_schema.versioned_base('simple_persistence', 4)

# Used to signify that a given key should be deleted from simple persistence on flush
DELETE = object()


@db_schema.upgrade('simple_persistence')
def upgrade(ver, session):
    if ver is None:
        # Upgrade to version 0 was a failed attempt at cleaning bad entries from our table, better attempt in ver 1
        ver = 0
    if ver == 0:
        try:
            # Remove any values that are not loadable.
            table = table_schema('simple_persistence', session)
            for row in session.execute(
コード例 #14
0
from flexget import db_schema, plugin
from flexget import logging
from flexget.db_schema import UpgradeImpossible
from flexget.event import event
from flexget.utils.database import with_session
from flexget.utils.log import log_once
from sqlalchemy import Table, Column, Integer, Float, String, Unicode, DateTime, Text, Date
from sqlalchemy.orm import relation, relationship
from sqlalchemy.schema import ForeignKey, Index

from .util import AnidbParser, AnidbSearch

SCHEMA_VER = 1

Base = db_schema.versioned_base('fadbs_lookup', SCHEMA_VER)

creators_table = Table(
    'anidb_anime_creators', Base.metadata,
    Column('anidb_id', Integer, ForeignKey('anidb_series.id')),
    Column('creator_id', Integer, ForeignKey('anidb_creators.id')),
    Index('ix_anidb_anime_creators', 'anidb_id', 'creator_id'))
Base.register_table(creators_table)

# characters_table = Table('anidb_anime_characters', Base.metadata,
#                          Column('anidb_id', Integer, ForeignKey('anidb_series.id')),
#                          Column('character_id', Integer, ForeignKey('anidb_characters.id')),
#                          Index('ix_anidb_anime_characters', 'anidb_id', 'character_id'))
# Base.register_table(characters_table)

episodes_table = Table(
コード例 #15
0
from __future__ import unicode_literals, division, absolute_import
import hashlib
import logging

from sqlalchemy import Column, Integer, Unicode

from flexget import db_schema, plugin
from flexget.event import event
from flexget.plugins.filter.series import FilterSeriesBase

log = logging.getLogger('configure_series')
Base = db_schema.versioned_base('import_series', 0)


class LastHash(Base):
    __tablename__ = 'import_series_last_hash'

    id = Column(Integer, primary_key=True)
    task = Column(Unicode)
    hash = Column(Unicode)


class ImportSeries(FilterSeriesBase):

    """Generates series configuration from any input (supporting API version 2, soon all)

    Configuration::

      configure_series:
        [settings]:
           # same configuration as series plugin
コード例 #16
0
ファイル: subtitle_queue.py プロジェクト: thomaswr/Flexget
from flexget.event import event
from flexget.manager import Session
from flexget.utils.database import with_session
from flexget.utils.template import RenderError
from flexget.utils.tools import parse_timedelta

try:
    from babelfish import Language
except ImportError:
    raise plugin.DependencyError(
        issued_by='subtitle_queue',
        missing='babelfish',
        message='subtitle_queue requires the babelfish plugin')

log = logging.getLogger('subtitle_queue')
Base = db_schema.versioned_base('subtitle_queue', 0)

#: Video extensions stolen from https://github.com/Diaoul/subliminal/blob/master/subliminal/video.py
VIDEO_EXTENSIONS = ('.3g2', '.3gp', '.3gp2', '.3gpp', '.60d', '.ajp', '.asf',
                    '.asx', '.avchd', '.avi', '.bik', '.bix', '.box', '.cam',
                    '.dat', '.divx', '.dmf', '.dv', '.dvr-ms', '.evo', '.flc',
                    '.fli', '.flic', '.flv', '.flx', '.gvi', '.gvp', '.h264',
                    '.m1v', '.m2p', '.m2ts', '.m2v', '.m4e', '.m4v', '.mjp',
                    '.mjpeg', '.mjpg', '.mkv', '.moov', '.mov', '.movhd',
                    '.movie', '.movx', '.mp4', '.mpe', '.mpeg', '.mpg', '.mpv',
                    '.mpv2', '.mxf', '.nsv', '.nut', '.ogg', '.ogm', '.omf',
                    '.ps', '.qt', '.ram', '.rm', '.rmvb', '.swf', '.ts',
                    '.vfw', '.vid', '.video', '.viv', '.vivo', '.vob', '.vro',
                    '.wm', '.wmv', '.wmx', '.wrap', '.wvx', '.wx', '.x264',
                    '.xvid')
コード例 #17
0
ファイル: backlog.py プロジェクト: AlinaKay/Flexget
import logging
import pickle
from datetime import datetime

from sqlalchemy import Column, Integer, String, Unicode, DateTime, Index, select

from flexget import db_schema, plugin
from flexget.event import event
from flexget.utils import json
from flexget.manager import Session
from flexget.utils.database import entry_synonym, with_session
from flexget.utils.tools import parse_timedelta
from flexget.utils.sqlalchemy_utils import table_schema, table_add_column

log = logging.getLogger('backlog')
Base = db_schema.versioned_base('backlog', 2)


@db_schema.upgrade('backlog')
def upgrade(ver, session):
    if ver is None:
        # Make sure there is no data we can't load in the backlog table
        backlog_table = table_schema('backlog', session)
        try:
            for item in session.query('entry').select_from(backlog_table).all():
                pickle.loads(item.entry)
        except (ImportError, TypeError):
            # If there were problems, we can drop the data.
            log.info('Backlog table contains unloadable data, clearing old data.')
            session.execute(backlog_table.delete())
        ver = 0
コード例 #18
0
import difflib
from datetime import datetime, timedelta

from sqlalchemy import Table, Column, Integer, String, DateTime, func, sql
from sqlalchemy.schema import ForeignKey, Index
from sqlalchemy.orm import relation

from flexget import db_schema
from flexget.plugin import internet, PluginError
from flexget.utils import requests
from flexget.utils.database import text_date_synonym, with_session
from flexget.utils.sqlalchemy_utils import table_schema, table_add_column
from flexget import plugin

log = logging.getLogger('api_rottentomatoes')
Base = db_schema.versioned_base('api_rottentomatoes', 2)
session = requests.Session()
# There is a 5 call per second rate limit per api key with multiple users on the same api key, this can be problematic
session.add_domain_limiter(
    requests.TimedLimiter('api.rottentomatoes.com', '0.4 seconds'))

# This is developer Atlanta800's API key
API_KEY = 'rh8chjzp8vu6gnpwj88736uv'
API_VER = 'v1.0'
SERVER = 'http://api.rottentomatoes.com/api/public'

MIN_MATCH = 0.5
MIN_DIFF = 0.01


@db_schema.upgrade('api_rottentomatoes')
コード例 #19
0
import logging
from datetime import datetime, timedelta

from sqlalchemy import Column, Integer, String, Unicode, DateTime, ForeignKey, and_, Index
from sqlalchemy.orm import relation

from flexget import db_schema, options, plugin
from flexget.event import event
from flexget.logger import console
from flexget.manager import Session
from flexget.utils.sqlalchemy_utils import table_columns, table_add_column
from flexget.utils.tools import parse_timedelta

log = logging.getLogger('remember_rej')
Base = db_schema.versioned_base('remember_rejected', 3)


@db_schema.upgrade('remember_rejected')
def upgrade(ver, session):
    if ver is None:
        columns = table_columns('remember_rejected_entry', session)
        if 'uid' in columns:
            raise db_schema.UpgradeImpossible
        ver = 0
    if ver == 0:
        log.info('Adding reason column to remember_rejected_entry table.')
        table_add_column('remember_rejected_entry', 'reason', String, session)
        ver = 1
    if ver == 1:
        log.info('Adding `added` column to remember_rejected_entry table.')
コード例 #20
0
ファイル: torrent411.py プロジェクト: oscarb-se/Flexget
from flexget.utils.soup import get_soup
from flexget.utils.search import torrent_availability, normalize_unicode

from flexget.manager import Session
from flexget.db_schema import versioned_base
from requests.auth import AuthBase

from datetime import datetime, timedelta

from sqlalchemy.types import TypeDecorator, VARCHAR
from sqlalchemy import Column, Unicode, Integer, DateTime

__author__ = 'blAStcodeM'

log = logging.getLogger('torrent411')
Base = versioned_base('torrent411', 0)

CATEGORIES = {
    'Animation': 455,
    'Animation-Serie': 637,
    'Concert': 633,
    'Documentaire': 634,
    'Emission-TV': 639,
    'Film': 631,
    'Serie-TV': 433,
    'Series': 1,
    'Spectacle': 635,
    'Sport': 636,
    'Video-clips': 402
}
コード例 #21
0
ファイル: thetvdb_favorites.py プロジェクト: Anaerin/Flexget
from flexget.plugin import register_plugin, internet, DependencyError
from flexget.utils.tools import urlopener
from flexget.utils.database import pipe_list_synonym, with_session
from flexget.utils.sqlalchemy_utils import drop_tables, table_columns
from flexget.utils.cached_input import cached
from flexget.entry import Entry

try:
    from flexget.plugins.api_tvdb import lookup_series
except ImportError:
    raise DependencyError(
        issued_by="thetvdb_favorites", missing="api_tvdb", message="thetvdb_lookup requires the `api_tvdb` plugin"
    )

log = logging.getLogger("thetvdb_favorites")
Base = db_schema.versioned_base("thetvdb_favorites", 0)


@db_schema.upgrade("thetvdb_favorites")
def upgrade(ver, session):
    if ver is None:
        columns = table_columns("thetvdb_favorites", session)
        if not "series_ids" in columns:
            # Drop the old table
            log.info("Dropping old version of thetvdb_favorites table from db")
            drop_tables(["thetvdb_favorites"], session)
            # Create new table from the current model
            Base.metadata.create_all(bind=session.bind)
        ver = 0
    return ver
コード例 #22
0
from flexget import config_schema, db_schema
from flexget.entry import EntryUnicodeError
from flexget.event import event, fire_event
from flexget.logger import capture_output
from flexget.manager import Session
from flexget.plugin import plugins as all_plugins
from flexget.plugin import (DependencyError, get_plugins, phase_methods,
                            plugin_schemas, PluginError, PluginWarning,
                            task_phases)
from flexget.utils import requests
from flexget.utils.database import with_session
from flexget.utils.simple_persistence import SimpleTaskPersistence

log = logging.getLogger('task')
Base = db_schema.versioned_base('feed', 0)


class TaskConfigHash(Base):
    """Stores the config hash for tasks so that we can tell if the config has changed since last run."""

    __tablename__ = 'feed_config_hash'

    id = Column(Integer, primary_key=True)
    task = Column('name', Unicode, index=True, nullable=False)
    hash = Column('hash', String)

    def __repr__(self):
        return '<TaskConfigHash(task=%s,hash=%s)>' % (self.task, self.hash)

コード例 #23
0
ファイル: subtitle_queue.py プロジェクト: MikeyCanuck/Flexget
from flexget import db_schema, plugin
from flexget.entry import Entry
from flexget.event import event
from flexget.manager import Session
from flexget.utils.database import with_session
from flexget.utils.template import RenderError
from flexget.utils.tools import parse_timedelta

try:
    from babelfish import Language
except ImportError:
    raise plugin.DependencyError(issued_by='subtitle_queue', missing='babelfish',
                                 message='subtitle_queue requires the babelfish plugin')

log = logging.getLogger('subtitle_queue')
Base = db_schema.versioned_base('subtitle_queue', 0)


#: Video extensions stolen from https://github.com/Diaoul/subliminal/blob/master/subliminal/video.py
VIDEO_EXTENSIONS = ('.3g2', '.3gp', '.3gp2', '.3gpp', '.60d', '.ajp', '.asf', '.asx', '.avchd', '.avi', '.bik',
                    '.bix', '.box', '.cam', '.dat', '.divx', '.dmf', '.dv', '.dvr-ms', '.evo', '.flc', '.fli',
                    '.flic', '.flv', '.flx', '.gvi', '.gvp', '.h264', '.m1v', '.m2p', '.m2ts', '.m2v', '.m4e',
                    '.m4v', '.mjp', '.mjpeg', '.mjpg', '.mkv', '.moov', '.mov', '.movhd', '.movie', '.movx', '.mp4',
                    '.mpe', '.mpeg', '.mpg', '.mpv', '.mpv2', '.mxf', '.nsv', '.nut', '.ogg', '.ogm', '.omf', '.ps',
                    '.qt', '.ram', '.rm', '.rmvb', '.swf', '.ts', '.vfw', '.vid', '.video', '.viv', '.vivo', '.vob',
                    '.vro', '.wm', '.wmv', '.wmx', '.wrap', '.wvx', '.wx', '.x264', '.xvid')


SUBTITLE_EXTENSIONS = ('.srt', '.sub', '.smi', '.txt', '.ssa', '.ass', '.mpl')  # Borrowed from Subliminal

コード例 #24
0
from loguru import logger
from sqlalchemy import Column, DateTime, Integer, Unicode, select

from flexget import db_schema, plugin
from flexget.config_schema import one_or_more
from flexget.db_schema import versioned_base
from flexget.entry import Entry, EntryState
from flexget.event import event
from flexget.manager import Session
from flexget.utils import json, serialization
from flexget.utils.database import entry_synonym
from flexget.utils.sqlalchemy_utils import table_add_column, table_schema
from flexget.utils.tools import parse_timedelta

logger = logger.bind(name='digest')
Base = versioned_base('digest', 2)


@db_schema.upgrade('digest')
def upgrade(ver, session):
    if None is ver:
        ver = 0
    if ver == 0:
        table = table_schema('digest_entries', session)
        table_add_column(table, 'json', Unicode, session)
        # Make sure we get the new schema with the added column
        table = table_schema('digest_entries', session)
        for row in session.execute(select([table.c.id, table.c.entry])):
            try:
                p = pickle.loads(row['entry'])
                session.execute(
コード例 #25
0
from datetime import datetime, timedelta

from sqlalchemy.orm import relation
from sqlalchemy import Column, Integer, String, DateTime, Unicode, select, ForeignKey

from flexget import db_schema
from flexget.manager import Session
from flexget.utils import json
from flexget.utils.database import entry_synonym
from flexget.utils.tools import parse_timedelta, TimedDict
from flexget.event import event
from flexget.plugin import PluginError
from flexget.utils.sqlalchemy_utils import table_schema, table_add_column

log = logging.getLogger('input_cache')
Base = db_schema.versioned_base('input_cache', 1)


@db_schema.upgrade('input_cache')
def upgrade(ver, session):
    if ver == 0:
        table = table_schema('input_cache_entry', session)
        table_add_column(table, 'json', Unicode, session)
        # Make sure we get the new schema with the added column
        table = table_schema('input_cache_entry', session)
        for row in session.execute(select([table.c.id, table.c.entry])):
            try:
                p = pickle.loads(row['entry'])
                session.execute(table.update().where(table.c.id == row['id']).values(
                    json=json.dumps(p, encode_datetime=True)))
            except KeyError as e:
コード例 #26
0
ファイル: api_trakt.py プロジェクト: Marmau/Flexget
from sqlalchemy.orm import relation, object_session
from sqlalchemy.schema import ForeignKey

from flexget import db_schema
from flexget import plugin
from flexget import options
from flexget.db_schema import upgrade
from flexget.event import event
from flexget.manager import Session
from flexget.plugin import get_plugin_by_name
from flexget.utils import requests
from flexget.utils.database import with_session
from flexget.utils.simple_persistence import SimplePersistence
from flexget.logger import console

Base = db_schema.versioned_base('api_trakt', 3)
log = logging.getLogger('api_trakt')
# Production Site
CLIENT_ID = '57e188bcb9750c79ed452e1674925bc6848bd126e02bb15350211be74c6547af'
CLIENT_SECRET = 'db4af7531e8df678b134dbc22445a2c04ebdbdd7213be7f5b6d17dfdfabfcdc2'
API_URL = 'https://api-v2launch.trakt.tv/'
PIN_URL = 'http://trakt.tv/pin/346'
# Stores the last time we checked for updates for shows/movies
updated = SimplePersistence('api_trakt')


# Oauth account authentication
class TraktUserAuth(Base):
    __tablename__ = 'trakt_user_auth'

    account = Column(Unicode, primary_key=True)
コード例 #27
0
ファイル: archive.py プロジェクト: DColl/Flexget
from sqlalchemy.schema import Table, ForeignKey
from sqlalchemy import Column, Integer, DateTime, Unicode, Index

from flexget import db_schema, options, plugin
from flexget.event import event
from flexget.entry import Entry
from flexget.options import ParseExtrasAction, get_parser
from flexget.utils.sqlalchemy_utils import table_schema, get_index_by_name
from flexget.utils.tools import console, strip_html
from flexget.manager import Session

log = logging.getLogger('archive')

SCHEMA_VER = 0

Base = db_schema.versioned_base('archive', SCHEMA_VER)

archive_tags_table = Table('archive_entry_tags', Base.metadata,
                           Column('entry_id', Integer, ForeignKey('archive_entry.id')),
                           Column('tag_id', Integer, ForeignKey('archive_tag.id')),
                           Index('ix_archive_tags', 'entry_id', 'tag_id'))

archive_sources_table = Table('archive_entry_sources', Base.metadata,
                              Column('entry_id', Integer, ForeignKey('archive_entry.id')),
                              Column('source_id', Integer, ForeignKey('archive_source.id')),
                              Index('ix_archive_sources', 'entry_id', 'source_id'))


class ArchiveEntry(Base):
    __tablename__ = 'archive_entry'
    __table_args__ = (Index('ix_archive_title_url', 'title', 'url'),)
コード例 #28
0
import logging
import re
from datetime import datetime

from sqlalchemy import Column, Integer, Unicode

from flexget import plugin
from flexget.db_schema import versioned_base
from flexget.event import event
from flexget.utils import requests
from flexget.utils.parsers.generic import name_to_re
from flexget.utils.soup import get_soup

log = logging.getLogger('pogcal_acquired')
Base = versioned_base('pogcal_acquired', 0)
session = requests.Session(max_retries=3)


class PogcalShow(Base):
    __tablename__ = 'pogcal_shows'
    id = Column(Integer, primary_key=True, autoincrement=False, nullable=False)
    name = Column(Unicode)


class PogcalAcquired:
    schema = {
        'type': 'object',
        'properties': {
            'username': {
                'type': 'string'
            },
コード例 #29
0
ファイル: api_tvrage.py プロジェクト: Gyran/Flexget
from socket import timeout

from sqlalchemy import Column, Integer, DateTime, String, Unicode, ForeignKey, select, update
from sqlalchemy.orm import relation
import tvrage.api

from flexget.event import event
from flexget.utils.database import with_session
from flexget import db_schema
from flexget.utils.database import pipe_list_synonym
from flexget.utils.sqlalchemy_utils import table_schema
from flexget.utils.tools import parse_timedelta

log = logging.getLogger('api_tvrage')

Base = db_schema.versioned_base('tvrage', 1)
update_interval = '7 days'


@event('manager.db_cleanup')
def db_cleanup(session):
    value = datetime.datetime.now() - parse_timedelta('30 days')
    for de in session.query(TVRageSeries).filter(TVRageSeries.last_update <= value).all():
        log.debug('deleting %s' % de)
        session.delete(de)


@db_schema.upgrade('tvrage')
def upgrade(ver, session):
    if ver == 0:
        series_table = table_schema('tvrage_series', session)
コード例 #30
0
ファイル: passthepopcorn.py プロジェクト: luizoti/Flexget
from requests.exceptions import TooManyRedirects
from sqlalchemy import Column, DateTime, Unicode

from flexget import db_schema, plugin
from flexget.config_schema import one_or_more
from flexget.entry import Entry
from flexget.event import event
from flexget.manager import Session
from flexget.utils.database import json_synonym
from flexget.utils.requests import RequestException
from flexget.utils.requests import Session as RequestSession
from flexget.utils.requests import TimedLimiter
from flexget.utils.tools import parse_filesize

logger = logger.bind(name='passthepopcorn')
Base = db_schema.versioned_base('passthepopcorn', 1)

requests = RequestSession()
requests.add_domain_limiter(TimedLimiter('passthepopcorn.me', '5 seconds'))

TAGS = [
    'action',
    'adventure',
    'animation',
    'arthouse',
    'asian',
    'biography',
    'camp',
    'comedy',
    'crime',
    'cult',
コード例 #31
0
ファイル: passthepopcorn.py プロジェクト: Flexget/Flexget
from requests.exceptions import TooManyRedirects
from sqlalchemy import Column, Unicode, DateTime
from dateutil.parser import parse as dateutil_parse

from flexget import plugin, db_schema
from flexget.config_schema import one_or_more
from flexget.entry import Entry
from flexget.event import event
from flexget.manager import Session
from flexget.utils.database import json_synonym
from flexget.utils.requests import Session as RequestSession, TimedLimiter, RequestException
from flexget.utils.tools import parse_filesize

log = logging.getLogger('passthepopcorn')
Base = db_schema.versioned_base('passthepopcorn', 1)

requests = RequestSession()
requests.add_domain_limiter(TimedLimiter('passthepopcorn.me', '5 seconds'))

TAGS = [
    'action',
    'adventure',
    'animation',
    'arthouse',
    'asian',
    'biography',
    'camp',
    'comedy',
    'crime',
    'cult',
コード例 #32
0
ファイル: api_tvdb.py プロジェクト: itsamenathan/Flexget
import logging
from datetime import datetime, timedelta

from sqlalchemy import Table, Column, Integer, Float, Unicode, Boolean, DateTime
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.orm import relation
from sqlalchemy.schema import ForeignKey

from flexget import db_schema
from flexget.utils import requests
from flexget.utils.tools import split_title_year
from flexget.utils.database import with_session, text_date_synonym, json_synonym
from flexget.utils.simple_persistence import SimplePersistence

log = logging.getLogger('api_tvdb')
Base = db_schema.versioned_base('api_tvdb', 7)

# This is a FlexGet API key
persist = SimplePersistence('api_tvdb')

SEARCH_RESULT_EXPIRATION_DAYS = 3


class TVDBRequest(object):
    API_KEY = '4D297D8CFDE0E105'
    BASE_URL = 'https://api.thetvdb.com/'
    BANNER_URL = 'http://thetvdb.com/banners/'

    def __init__(self, username=None, account_id=None):
        self.username = username
        self.account_id = account_id
コード例 #33
0
ファイル: imdb_lookup.py プロジェクト: Gyran/Flexget
from sqlalchemy.schema import ForeignKey, Index
from sqlalchemy.orm import relation, joinedload_all

from flexget import db_schema
from flexget.entry import Entry
from flexget.plugin import register_plugin, internet, PluginError, priority
from flexget.manager import Session
from flexget.utils.log import log_once
from flexget.utils.imdb import ImdbSearch, ImdbParser, extract_id, make_url
from flexget.utils.sqlalchemy_utils import table_add_column
from flexget.utils.database import with_session
from flexget.utils.sqlalchemy_utils import table_columns, get_index_by_name, table_schema

SCHEMA_VER = 4

Base = db_schema.versioned_base('imdb_lookup', SCHEMA_VER)


# association tables
genres_table = Table('imdb_movie_genres', Base.metadata,
    Column('movie_id', Integer, ForeignKey('imdb_movies.id')),
    Column('genre_id', Integer, ForeignKey('imdb_genres.id')),
    Index('ix_imdb_movie_genres', 'movie_id', 'genre_id'))

actors_table = Table('imdb_movie_actors', Base.metadata,
    Column('movie_id', Integer, ForeignKey('imdb_movies.id')),
    Column('actor_id', Integer, ForeignKey('imdb_actors.id')),
    Index('ix_imdb_movie_actors', 'movie_id', 'actor_id'))

directors_table = Table('imdb_movie_directors', Base.metadata,
    Column('movie_id', Integer, ForeignKey('imdb_movies.id')),
コード例 #34
0
import logging
import re
from collections import MutableSet
from datetime import datetime

from sqlalchemy import Column, DateTime, ForeignKey, Integer, Unicode, and_, func
from sqlalchemy.orm import relationship

from flexget import plugin
from flexget.db_schema import versioned_base, with_session
from flexget.entry import Entry
from flexget.event import event
from flexget.manager import Session

log = logging.getLogger('regexp_list')
Base = versioned_base('regexp_list', 1)


class RegexpListList(Base):
    __tablename__ = 'regexp_list_lists'
    id = Column(Integer, primary_key=True)
    name = Column(Unicode, unique=True)
    added = Column(DateTime, default=datetime.now)
    regexps = relationship('RegexListRegexp',
                           backref='list',
                           cascade='all, delete, delete-orphan',
                           lazy='dynamic')

    def __repr__(self):
        return '<RegexpListList name=%s,id=%d>' % (self.name, self.id)
コード例 #35
0
ファイル: task.py プロジェクト: BrainDamage/Flexget
import logging

from sqlalchemy import Column, Unicode, String, Integer

from flexget import config_schema
from flexget import db_schema
from flexget.entry import EntryUnicodeError
from flexget.event import fire_event, event
from flexget.manager import Session
from flexget.plugin import (get_plugins, task_phases, phase_methods, PluginWarning, PluginError,
                            DependencyError, plugins as all_plugins, plugin_schemas)
from flexget.utils import requests
from flexget.utils.simple_persistence import SimpleTaskPersistence

log = logging.getLogger('task')
Base = db_schema.versioned_base('feed', 0)


class TaskConfigHash(Base):
    """Stores the config hash for tasks so that we can tell if the config has changed since last run."""

    __tablename__ = 'feed_config_hash'

    id = Column(Integer, primary_key=True)
    task = Column('name', Unicode, index=True, nullable=False)
    hash = Column('hash', String)

    def __repr__(self):
        return '<TaskConfigHash(task=%s,hash=%s)>' % (self.task, self.hash)

コード例 #36
0
ファイル: api_tvmaze.py プロジェクト: paulcunnane/Flexget
from requests.exceptions import RequestException
from sqlalchemy import Column, Integer, Float, DateTime, String, Unicode, ForeignKey, Table, or_, \
    and_
from sqlalchemy.orm import relation
from sqlalchemy.orm.exc import MultipleResultsFound

from flexget import db_schema, plugin
from flexget.event import event
from flexget.utils import requests
from flexget.utils.database import with_session, json_synonym
from flexget.utils.tools import split_title_year

log = logging.getLogger('api_tvmaze')

DB_VERSION = 6
Base = db_schema.versioned_base('tvmaze', DB_VERSION)
UPDATE_INTERVAL = 7  # Used for expiration, number is in days
BASE_URL = 'http://api.tvmaze.com'

TVMAZE_ENDPOINTS = {
    'tvmaze_id': '/shows/{}',
    'imdb_id': '/lookup/shows?imdb={}',
    'tvrage_id': '/lookup/shows?tvrage={}',
    'thetvdb_id': '/lookup/shows?thetvdb={}',
    'show_name': '/singlesearch/shows?q={}',
    'date': '/shows/{}/episodesbydate?date={}',
    'number': '/shows/{}/episodebynumber?season={}&number={}'
}


@db_schema.upgrade('tvmaze')
コード例 #37
0
ファイル: api_tvmaze.py プロジェクト: Farbdose/Flexget
from future.utils import native
from requests.exceptions import HTTPError
from sqlalchemy import Column, Integer, Float, DateTime, String, Unicode, ForeignKey, func, Table, or_, \
    and_
from sqlalchemy.orm import relation

from flexget import db_schema, plugin
from flexget.event import event
from flexget.utils import requests
from flexget.utils.database import with_session, json_synonym
from flexget.utils.tools import split_title_year

log = logging.getLogger('api_tvmaze')

DB_VERSION = 5
Base = db_schema.versioned_base('tvmaze', DB_VERSION)
UPDATE_INTERVAL = 7  # Used for expiration, number is in days
BASE_URL = 'http://api.tvmaze.com'

TVMAZE_ENDPOINTS = {
    'tvmaze_id': '/shows/{}',
    'imdb_id': '/lookup/shows?imdb={}',
    'tvrage_id': '/lookup/shows?tvrage={}',
    'thetvdb_id': '/lookup/shows?thetvdb={}',
    'show_name': '/singlesearch/shows?q={}',
    'date': '/shows/{}/episodesbydate?date={}',
    'number': '/shows/{}/episodebynumber?season={}&number={}'
}


@db_schema.upgrade('tvmaze')
コード例 #38
0
ファイル: api_tmdb.py プロジェクト: tsnoam/Flexget
from flexget.manager import Session
from flexget.plugin import get_plugin_by_name
from flexget.utils import requests
from flexget.utils.database import text_date_synonym, year_property, with_session
from flexget.utils.sqlalchemy_utils import table_add_column, table_schema

try:
    import tmdb3
except ImportError:
    raise plugin.DependencyError(
        issued_by='api_tmdb',
        missing='tmdb3',
        message='TMDB requires https://github.com/wagnerrp/pytmdb3')

log = logging.getLogger('api_tmdb')
Base = db_schema.versioned_base('api_tmdb', 0)

# This is a FlexGet API key
tmdb3.tmdb_api.set_key('bdfc018dbdb7c243dc7cb1454ff74b95')
tmdb3.locales.set_locale("en", "us", True)
# There is a bug in tmdb3 library, where it uses the system encoding for query parameters, tmdb expects utf-8 #2392
tmdb3.locales.syslocale.encoding = 'utf-8'
tmdb3.set_cache('null')


@db_schema.upgrade('api_tmdb')
def upgrade(ver, session):
    if ver is None:
        log.info(
            'Adding columns to tmdb cache table, marking current cache as expired.'
        )
コード例 #39
0
ファイル: myepisodes.py プロジェクト: Flexget/Flexget
from builtins import *  # noqa pylint: disable=unused-import, redefined-builtin

import logging
import re
from datetime import datetime

from sqlalchemy import Column, Integer, String, DateTime

from flexget import plugin
from flexget.event import event
from flexget.utils import requests
from flexget.db_schema import versioned_base


log = logging.getLogger('myepisodes')
Base = versioned_base('myepisodes', 0)


class MyEpisodesInfo(Base):
    __tablename__ = 'myepisodes'

    id = Column(Integer, primary_key=True)
    series_name = Column(String, unique=True)
    myepisodes_id = Column(Integer, unique=True)
    updated = Column(DateTime)

    def __init__(self, series_name, myepisodes_id):
        self.series_name = series_name
        self.myepisodes_id = myepisodes_id
        self.updated = datetime.now()
コード例 #40
0
import logging
from builtins import *  # noqa pylint: disable=unused-import, redefined-builtin
from datetime import datetime, timedelta

from sqlalchemy import Column, Integer, String, Unicode, DateTime
from sqlalchemy.schema import Index

from flexget import db_schema
from flexget.event import event
from flexget.utils.sqlalchemy_utils import table_add_column

SCHEMA_VER = 3
FAIL_LIMIT = 100

log = logging.getLogger('failed.db')
Base = db_schema.versioned_base('failed', SCHEMA_VER)


@db_schema.upgrade('failed')
def upgrade(ver, session):
    if ver is None or ver < 1:
        raise db_schema.UpgradeImpossible
    if ver == 1:
        table_add_column('failed', 'reason', Unicode, session)
        ver = 2
    if ver == 2:
        table_add_column('failed', 'retry_time', DateTime, session)
        ver = 3
    return ver

コード例 #41
0
ファイル: morethantv.py プロジェクト: Davst/Flexget
from sqlalchemy import Column, Unicode, DateTime

from flexget import plugin, db_schema
from flexget.entry import Entry
from flexget.event import event
from flexget.utils.requests import TimedLimiter, RequestException
from flexget.manager import Session
from flexget.utils.database import json_synonym
from flexget.utils.requests import Session as RequestSession
from flexget.utils.soup import get_soup
from flexget.config_schema import one_or_more
from flexget.utils.tools import parse_filesize

log = logging.getLogger('morethantv')
Base = db_schema.versioned_base('morethantv', 0)

requests = RequestSession()
requests.add_domain_limiter(TimedLimiter('morethan.tv', '5 seconds'))  # TODO find out if they want a delay

CATEGORIES = {
    'Movies': 'filter_cat[1]',
    'TV': 'filter_cat[2]',
    'Other': 'filter_cat[3]'
}

TAGS = [
    'action',
    'adventure',
    'animation',
    'anime',
コード例 #42
0
from flexget.utils import qualities
from flexget.utils.imdb import extract_id
from flexget.utils.log import log_once
from flexget.utils.database import quality_requirement_property, with_session
from flexget.utils.sqlalchemy_utils import table_exists, table_schema

try:
    from flexget.plugins.filter import queue_base
except ImportError:
    raise plugin.DependencyError(
        issued_by='movie_queue',
        missing='queue_base',
        message='movie_queue requires the queue_base plugin')

log = logging.getLogger('movie_queue')
Base = db_schema.versioned_base('movie_queue', 2)


@event('manager.lock_acquired')
def migrate_imdb_queue(manager):
    """If imdb_queue table is found, migrate the data to movie_queue"""
    session = Session()
    try:
        if table_exists('imdb_queue', session):
            log.info('Migrating imdb_queue items to movie_queue')
            old_table = table_schema('imdb_queue', session)
            for row in session.execute(old_table.select()):
                try:
                    queue_add(imdb_id=row['imdb_id'],
                              quality=row['quality'],
                              session=session)
コード例 #43
0
ファイル: rss.py プロジェクト: totesmuhgoats/Flexget
from __future__ import unicode_literals, division, absolute_import
import base64
import hashlib
import logging
import datetime
import os

from sqlalchemy import Column, Integer, String, DateTime, Unicode

from flexget import db_schema, plugin
from flexget.event import event
from flexget.utils.sqlalchemy_utils import table_columns, table_add_column
from flexget.utils.template import render_from_entry, get_template, RenderError

log = logging.getLogger('make_rss')
Base = db_schema.versioned_base('make_rss', 0)

rss2gen = True
try:
    import PyRSS2Gen
except:
    rss2gen = False


@db_schema.upgrade('make_rss')
def upgrade(ver, session):
    if ver is None:
        columns = table_columns('make_rss', session)
        if not 'rsslink' in columns:
            log.info('Adding rsslink column to table make_rss.')
            table_add_column('make_rss', 'rsslink', String, session)
コード例 #44
0
ファイル: rutracker.py プロジェクト: luizoti/Flexget
from requests.auth import AuthBase
from requests.exceptions import RequestException
from requests.utils import dict_from_cookiejar
from sqlalchemy import Column, DateTime, Integer, Unicode
from sqlalchemy.types import VARCHAR, TypeDecorator

from flexget import plugin
from flexget.db_schema import versioned_base
from flexget.event import event
from flexget.manager import Session
from flexget.plugin import PluginError

__author__ = 'asm0dey'

logger = logger.bind(name='rutracker_auth')
Base = versioned_base('rutracker_auth', 0)

MIRRORS = ['https://rutracker.net', 'https://rutracker.org']


class JSONEncodedDict(TypeDecorator):
    """Represents an immutable structure as a json-encoded string.

    Usage:

        JSONEncodedDict(255)

    """

    impl = VARCHAR
コード例 #45
0
ファイル: track_entry.py プロジェクト: stevezau/dotfiles
from __future__ import unicode_literals, division, absolute_import
import logging
from datetime import datetime
from sqlalchemy import Column, Integer, Unicode, DateTime, PickleType, Index

from flexget.utils.database import safe_pickle_synonym
from flexget import db_schema, plugin
from flexget.event import event

log = logging.getLogger('track_entry')

Base = db_schema.versioned_base('track_entry', 0)


class TrackEntry(Base):

    __tablename__ = 'track_entry'
    __table_args__ = (Index('ix_torrent_title_url_tag', 'title', 'url', 'tag'),)

    id = Column(Integer, primary_key=True)
    title = Column(Unicode, index=True)
    url = Column(Unicode, index=True)
    tag = Column(Unicode, index=True)
    state = Column(Unicode, index=True)
    updated = Column(DateTime, index=True)
    _entry = Column('entry', PickleType)
    entry = safe_pickle_synonym('_entry')

    def __init__(self):
        self.added = datetime.now()
コード例 #46
0
ファイル: version_checker.py プロジェクト: edetaillac/Flexget
from __future__ import unicode_literals, division, absolute_import
from builtins import *
from past.builtins import basestring

import logging
from datetime import datetime

from sqlalchemy import Column, DateTime

from flexget import db_schema, plugin
from flexget.event import event
from flexget.manager import Session
from flexget.utils.tools import get_latest_flexget_version_number, get_current_flexget_version

log = logging.getLogger('version_checker')
Base = db_schema.versioned_base('version_checker', 0)


class LastVersionCheck(Base):
    __tablename__ = 'last_version_check'

    last_check_time = Column(DateTime, primary_key=True)

    def __init__(self):
        self.update()

    def update(self):
        self.last_check_time = datetime.now()


schema = {
コード例 #47
0
ファイル: api_tvdb.py プロジェクト: Arhodes-CGRB-OSU/Flexget
from sqlalchemy.schema import ForeignKey
from sqlalchemy.orm import relation
from requests import RequestException

from flexget import db_schema
from flexget.utils.tools import decode_html
from flexget.utils.requests import Session as ReqSession
from flexget.utils.database import with_session, pipe_list_synonym, text_date_synonym
from flexget.utils.sqlalchemy_utils import table_add_column
from flexget.manager import Session
from flexget.utils.simple_persistence import SimplePersistence

SCHEMA_VER = 4

log = logging.getLogger('api_tvdb')
Base = db_schema.versioned_base('api_tvdb', SCHEMA_VER)
requests = ReqSession(timeout=25)

# This is a FlexGet API key
api_key = '4D297D8CFDE0E105'
language = 'en'
server = 'http://www.thetvdb.com/api/'
persist = SimplePersistence('api_tvdb')
_mirrors = {}


@db_schema.upgrade('api_tvdb')
def upgrade(ver, session):
    if ver is None:
        if 'last_updated' in persist:
            del persist['last_updated']
コード例 #48
0
ファイル: api_tvdb.py プロジェクト: sean797/Flexget
from sqlalchemy.schema import ForeignKey
from sqlalchemy.orm import relation
from requests import RequestException

from flexget import db_schema
from flexget.utils.tools import decode_html
from flexget.utils.requests import Session as ReqSession
from flexget.utils.database import with_session, pipe_list_synonym, text_date_synonym
from flexget.utils.sqlalchemy_utils import table_add_column
from flexget.manager import Session
from flexget.utils.simple_persistence import SimplePersistence

SCHEMA_VER = 4

log = logging.getLogger('api_tvdb')
Base = db_schema.versioned_base('api_tvdb', SCHEMA_VER)
requests = ReqSession(timeout=25)

# This is a FlexGet API key
api_key = '4D297D8CFDE0E105'
language = 'en'
server = 'http://www.thetvdb.com/api/'
_mirrors = {}
persist = SimplePersistence('api_tvdb')


@db_schema.upgrade('api_tvdb')
def upgrade(ver, session):
    if ver is None:
        if 'last_updated' in persist:
            del persist['last_updated']
コード例 #49
0
ファイル: movie_queue.py プロジェクト: awesome-python/Flexget
from flexget.event import event
from flexget.manager import Session
from flexget.utils import qualities
from flexget.utils.database import quality_requirement_property, with_session
from flexget.utils.imdb import extract_id
from flexget.utils.log import log_once
from flexget.utils.sqlalchemy_utils import table_exists, table_schema, table_add_column

try:
    from flexget.plugins.filter import queue_base
except ImportError:
    raise plugin.DependencyError(issued_by='movie_queue', missing='queue_base',
                                 message='movie_queue requires the queue_base plugin')

log = logging.getLogger('movie_queue')
Base = db_schema.versioned_base('movie_queue', 4)


@event('manager.lock_acquired')
def migrate_imdb_queue(manager):
    """If imdb_queue table is found, migrate the data to movie_queue"""
    session = Session()
    try:
        if table_exists('imdb_queue', session):
            log.info('Migrating imdb_queue items to movie_queue')
            old_table = table_schema('imdb_queue', session)
            for row in session.execute(old_table.select()):
                try:
                    queue_add(imdb_id=row['imdb_id'], quality=row['quality'], session=session)
                except QueueError as e:
                    log.error('Unable to migrate %s from imdb_queue to movie_queue' % row['title'])
コード例 #50
0
ファイル: archive.py プロジェクト: pilluli/Flexget
from sqlalchemy import Column, Integer, DateTime, Unicode, Index

from flexget import db_schema, options, plugin
from flexget.event import event
from flexget.entry import Entry
from flexget.logger import console
from flexget.options import ParseExtrasAction, get_parser
from flexget.utils.sqlalchemy_utils import table_schema, get_index_by_name
from flexget.utils.tools import strip_html
from flexget.manager import Session

log = logging.getLogger('archive')

SCHEMA_VER = 0

Base = db_schema.versioned_base('archive', SCHEMA_VER)

archive_tags_table = Table(
    'archive_entry_tags', Base.metadata,
    Column('entry_id', Integer, ForeignKey('archive_entry.id')),
    Column('tag_id', Integer, ForeignKey('archive_tag.id')),
    Index('ix_archive_tags', 'entry_id', 'tag_id'))
Base.register_table(archive_tags_table)

archive_sources_table = Table(
    'archive_entry_sources', Base.metadata,
    Column('entry_id', Integer, ForeignKey('archive_entry.id')),
    Column('source_id', Integer, ForeignKey('archive_source.id')),
    Index('ix_archive_sources', 'entry_id', 'source_id'))
Base.register_table(archive_sources_table)
コード例 #51
0
ファイル: api_trakt.py プロジェクト: Arhodes-CGRB-OSU/Flexget
from sqlalchemy.orm import relation, object_session
from sqlalchemy.schema import ForeignKey

from flexget import db_schema
from flexget import plugin
from flexget import options
from flexget.db_schema import upgrade
from flexget.event import event
from flexget.manager import Session
from flexget.plugin import get_plugin_by_name
from flexget.utils import requests
from flexget.utils.database import with_session
from flexget.utils.simple_persistence import SimplePersistence
from flexget.logger import console

Base = db_schema.versioned_base('api_trakt', 3)
log = logging.getLogger('api_trakt')
# Production Site
CLIENT_ID = '57e188bcb9750c79ed452e1674925bc6848bd126e02bb15350211be74c6547af'
CLIENT_SECRET = 'db4af7531e8df678b134dbc22445a2c04ebdbdd7213be7f5b6d17dfdfabfcdc2'
API_URL = 'https://api-v2launch.trakt.tv/'
PIN_URL = 'http://trakt.tv/pin/346'
# Stores the last time we checked for updates for shows/movies
updated = SimplePersistence('api_trakt')


# Oauth account authentication
class TraktUserAuth(Base):
    __tablename__ = 'trakt_user_auth'

    account = Column(Unicode, primary_key=True)
コード例 #52
0
ファイル: seen.py プロジェクト: shangshanshi/Flexget
import logging
from datetime import datetime

from sqlalchemy import Column, Integer, DateTime, Unicode, Boolean, or_, select, update, Index
from sqlalchemy.orm import relation
from sqlalchemy.schema import ForeignKey

from flexget import db_schema, plugin
from flexget.event import event
from flexget.manager import Session
from flexget.utils.database import with_session
from flexget.utils.imdb import extract_id
from flexget.utils.sqlalchemy_utils import table_schema, table_add_column

log = logging.getLogger('seen')
Base = db_schema.versioned_base('seen', 4)


@db_schema.upgrade('seen')
def upgrade(ver, session):
    if ver is None:
        log.info('Converting seen imdb_url to imdb_id for seen movies.')
        field_table = table_schema('seen_field', session)
        for row in session.execute(
                select([field_table.c.id, field_table.c.value],
                       field_table.c.field == 'imdb_url')):
            new_values = {
                'field': 'imdb_id',
                'value': extract_id(row['value'])
            }
            session.execute(
コード例 #53
0
ファイル: scheduler.py プロジェクト: parhuzamos/Flexget
import logging
import Queue
import threading
import time
import sys

from sqlalchemy import Column, String, DateTime

from flexget.config_schema import register_config_key, parse_time
from flexget.db_schema import versioned_base
from flexget.event import event
from flexget.logger import FlexGetFormatter
from flexget.manager import Session

log = logging.getLogger("scheduler")
Base = versioned_base("scheduler", 0)

UNITS = ["seconds", "minutes", "hours", "days", "weeks"]
WEEKDAYS = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]


yaml_schedule = {
    "type": "object",
    "properties": {
        "seconds": {"type": "number"},
        "minutes": {"type": "number"},
        "hours": {"type": "number"},
        "days": {"type": "number"},
        "weeks": {"type": "number"},
        "at_time": {"type": "string", "format": "time"},
        "on_day": {"type": "string", "enum": WEEKDAYS},
コード例 #54
0
_PLUGIN_NAME = 'telegram'

_PARSERS = ['markdown', 'html']

_TOKEN_ATTR = 'bot_token'
_MSG_ATTR = 'message'
_PARSE_ATTR = 'parse_mode'
_TEMPLATE_ATTR = 'file_template'
_RCPTS_ATTR = 'recipients'
_USERNAME_ATTR = 'username'
_FULLNAME_ATTR = 'fullname'
_FIRSTNAME_ATTR = 'first'
_SURNAME_ATTR = 'sur'
_GROUP_ATTR = 'group'

ChatIdsBase = db_schema.versioned_base('telegram_chat_ids', 0)


class ChatIdEntry(ChatIdsBase):
    __tablename__ = 'telegram_chat_ids'

    id = Column(Integer, primary_key=True)
    username = Column(String, index=True, nullable=True)
    firstname = Column(String, index=True, nullable=True)
    surname = Column(String, index=True, nullable=True)
    group = Column(String, index=True, nullable=True)

    def __str__(self):
        x = ['id={0}'.format(self.id)]
        if self.username:
            x.append('username={0}'.format(self.username))
コード例 #55
0
ファイル: discover.py プロジェクト: BrainDamage/Flexget
from __future__ import unicode_literals, division, absolute_import
import datetime
import logging
import random

from sqlalchemy import Column, Integer, DateTime, Unicode, Index

from flexget import options, plugin
from flexget.event import event
from flexget.plugin import get_plugin_by_name, PluginError, PluginWarning
from flexget import db_schema
from flexget.utils.tools import parse_timedelta, multiply_timedelta

log = logging.getLogger('discover')
Base = db_schema.versioned_base('discover', 0)


class DiscoverEntry(Base):
    __tablename__ = 'discover_entry'

    id = Column(Integer, primary_key=True)
    title = Column(Unicode, index=True)
    task = Column(Unicode, index=True)
    last_execution = Column(DateTime)

    def __init__(self, title, task):
        self.title = title
        self.task = task
        self.last_execution = None

    def __str__(self):
コード例 #56
0
ファイル: imdb_lookup.py プロジェクト: shangshanshi/Flexget
from sqlalchemy import Table, Column, Integer, Float, String, Unicode, Boolean, DateTime
from sqlalchemy.schema import ForeignKey, Index
from sqlalchemy.orm import relation

from flexget import db_schema, plugin
from flexget.db_schema import UpgradeImpossible
from flexget.event import event
from flexget.entry import Entry
from flexget.utils.log import log_once
from flexget.utils.imdb import ImdbSearch, ImdbParser, extract_id, make_url
from flexget.utils.database import with_session

SCHEMA_VER = 7

Base = db_schema.versioned_base('imdb_lookup', SCHEMA_VER)

# association tables
genres_table = Table('imdb_movie_genres', Base.metadata,
                     Column('movie_id', Integer, ForeignKey('imdb_movies.id')),
                     Column('genre_id', Integer, ForeignKey('imdb_genres.id')),
                     Index('ix_imdb_movie_genres', 'movie_id', 'genre_id'))
Base.register_table(genres_table)

actors_table = Table('imdb_movie_actors', Base.metadata,
                     Column('movie_id', Integer, ForeignKey('imdb_movies.id')),
                     Column('actor_id', Integer, ForeignKey('imdb_actors.id')),
                     Index('ix_imdb_movie_actors', 'movie_id', 'actor_id'))
Base.register_table(actors_table)

directors_table = Table('imdb_movie_directors', Base.metadata,
コード例 #57
0
ファイル: template.py プロジェクト: ghyster/Flexget
from __future__ import unicode_literals, division, absolute_import
from builtins import *  # noqa pylint: disable=unused-import, redefined-builtin
from past.builtins import basestring

import logging

from sqlalchemy import Column, Integer, String, Unicode

from flexget import options, plugin, db_schema
from flexget.event import event
from flexget.config_schema import register_config_key
from flexget.manager import Session
from flexget.utils.tools import MergeException, merge_dict_from_to

log = logging.getLogger('template')
Base = db_schema.versioned_base('template_hash', 0)


class TemplateConfigHash(Base):
    """Stores the config hash for tasks so that we can tell if the config has changed since last run."""

    __tablename__ = 'template_config_hash'

    id = Column(Integer, primary_key=True)
    task = Column('name', Unicode, index=True, nullable=False)
    hash = Column('hash', String)

    def __repr__(self):
        return '<TemplateConfigHash(task=%s,hash=%s)>' % (self.task, self.hash)

コード例 #58
0
ファイル: digest.py プロジェクト: AnthonyGuerreiro/Flexget
from datetime import datetime

from sqlalchemy import Column, Unicode, Integer, DateTime, select

from flexget import plugin, db_schema
from flexget.config_schema import one_or_more
from flexget.db_schema import versioned_base
from flexget.event import event
from flexget.manager import Session
from flexget.utils import json
from flexget.utils.database import entry_synonym
from flexget.utils.tools import parse_timedelta
from flexget.utils.sqlalchemy_utils import table_schema, table_add_column

log = logging.getLogger('digest')
Base = versioned_base('digest', 1)


@db_schema.upgrade('digest')
def upgrade(ver, session):
    if None is ver:
        ver = 0
    if ver == 0:
        table = table_schema('digest_entries', session)
        table_add_column(table, 'json', Unicode, session)
        # Make sure we get the new schema with the added column
        table = table_schema('digest_entries', session)
        for row in session.execute(select([table.c.id, table.c.entry])):
            try:
                p = pickle.loads(row['entry'])
                session.execute(table.update().where(table.c.id == row['id']).values(
コード例 #59
0
ファイル: retry_failed.py プロジェクト: ARLahan/Flexget
import logging
from datetime import datetime, timedelta

from sqlalchemy import Column, Integer, String, Unicode, DateTime
from sqlalchemy.schema import Index

from flexget import db_schema, options, plugin
from flexget.event import event
from flexget.manager import Session
from flexget.utils.tools import console, parse_timedelta
from flexget.utils.sqlalchemy_utils import table_add_column, table_schema

SCHEMA_VER = 2

log = logging.getLogger('failed')
Base = db_schema.versioned_base('failed', SCHEMA_VER)


@db_schema.upgrade('failed')
def upgrade(ver, session):
    if ver is None:
        # add count column
        table_add_column('failed', 'count', Integer, session, default=1)
        ver = 0
    if ver == 0:
        # define an index
        log.info('Adding database index ...')
        failed = table_schema('failed', session)
        Index('failed_title_url', failed.c.title, failed.c.url, failed.c.count).create()
        ver = 1
    if ver == 1:
コード例 #60
0
from __future__ import unicode_literals, division, absolute_import
import os
import re
import logging

from sqlalchemy import Column, Integer, Unicode

from flexget import options, plugin
from flexget.db_schema import versioned_base
from flexget.entry import Entry
from flexget.event import event
from flexget.manager import Session

log = logging.getLogger('tail')
Base = versioned_base('tail', 0)


class TailPosition(Base):
    __tablename__ = 'tail'
    id = Column(Integer, primary_key=True)
    task = Column(Unicode)
    filename = Column(Unicode)
    position = Column(Integer)


class InputTail(object):
    """
    Parse any text for entries using regular expression.

    ::