Ejemplo n.º 1
0
# Copyright (C) 2016  Allen Li
#
# This file is part of Animanager.
#
# Animanager is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Animanager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Animanager.  If not, see <http://www.gnu.org/licenses/>.

from animanager.cmd import ArgumentParser, Command
from animanager.db import query

parser = ArgumentParser(prog='reset')
parser.add_argument('aid')
parser.add_argument('episode', type=int)

def func(cmd, args):
    """Reset anime watched episodes."""
    aid = cmd.results.parse_aid(args.aid, default_key='db')
    query.update.reset(cmd.db, aid, args.episode)

command = Command(parser, func)
Ejemplo n.º 2
0
from animanager.cmd import ArgumentParser, Command
from animanager.date import fromtimestamp
from animanager.db import query
from animanager.db.query.eptype import EpisodeTypes

SHOW_MSG = """\
AID: {}
Title: {}
Type: {}
Episodes: {}/{}
Start date: {}
End date: {}
Complete: {}"""

parser = ArgumentParser(prog='show')
parser.add_argument('aid')
parser.add_argument(
    '-e', '--show-episodes',
    default=(), const=query.select.ALL, action='store_const',
    dest='episode_fields',
)

def func(cmd, args):
    """Show anime data."""
    aid = cmd.results.parse_aid(args.aid, default_key='db')
    anime = query.select.lookup(cmd.db, aid, episode_fields=args.episode_fields)

    complete_string = 'yes' if anime.complete else 'no'
    print(SHOW_MSG.format(
        anime.aid,
Ejemplo n.º 3
0
# Copyright (C) 2016  Allen Li
#
# This file is part of Animanager.
#
# Animanager is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Animanager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Animanager.  If not, see <http://www.gnu.org/licenses/>.

from animanager.cmd import ArgumentParser, Command
from animanager.db import query

parser = ArgumentParser(prog='deleterule')
parser.add_argument('id', type=int)

def func(cmd, args):
    """Delete priority rule."""
    query.files.delete_priority_rule(cmd.db, args.id)
    del cmd.file_picker

command = Command(parser, func)
Ejemplo n.º 4
0
#
# This file is part of Animanager.
#
# Animanager is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Animanager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Animanager.  If not, see <http://www.gnu.org/licenses/>.

from animanager.anidb import request_anime
from animanager.cmd import ArgumentParser, Command
from animanager.db import query

parser = ArgumentParser(prog='add')
parser.add_argument('aid')

def func(cmd, args):
    """Add an anime from an AniDB search."""
    aid = cmd.results.parse_aid(args.aid, default_key='anidb')
    anime = request_anime(aid)
    query.update.add(cmd.db, anime)

command = Command(parser, func)
Ejemplo n.º 5
0
#
# This file is part of Animanager.
#
# Animanager is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Animanager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Animanager.  If not, see <http://www.gnu.org/licenses/>.

from animanager.cmd import ArgumentParser, Command
from animanager.db import query

parser = ArgumentParser(prog='addrule')
parser.add_argument('regexp')
parser.add_argument('priority', nargs='?', default=None, type=int)

def func(cmd, args):
    """Add a priority rule for files."""
    row_id = query.files.add_priority_rule(cmd.db, args.regexp, args.priority)
    del cmd.file_picker
    print('Added rule {}'.format(row_id))

command = Command(parser, func)
Ejemplo n.º 6
0
#
# This file is part of Animanager.
#
# Animanager is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Animanager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Animanager.  If not, see <http://www.gnu.org/licenses/>.

from animanager.cmd import ArgumentParser, Command
from animanager.db import query

parser = ArgumentParser(prog="bump")
parser.add_argument("aid")


def func(cmd, args):
    """Bump anime."""
    aid = cmd.results.parse_aid(args.aid, default_key="db")
    query.update.bump(cmd.db, aid)


command = Command(parser, func)
Ejemplo n.º 7
0
#
# Animanager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Animanager.  If not, see <http://www.gnu.org/licenses/>.

import argparse
import re

from animanager.cmd import ArgumentParser, Command
from animanager.db import query

parser = ArgumentParser(prog='register')
parser.add_argument('aid')
parser.add_argument('query', nargs=argparse.REMAINDER)

def func(cmd, args):
    """Register watching regexp for an anime."""
    aid = cmd.results.parse_aid(args.aid, default_key='db')
    if args.query:
        # Use regexp provided by user.
        regexp = '.*'.join(args.query)
    else:
        # Make default regexp.
        title = query.select.lookup(cmd.db, aid, fields=['title']).title
        # Replace non-word, non-whitespace with whitespace.
        regexp = re.sub(r'[^\w\s]', ' ', title)
        # Split on whitespace and join with wildcard regexp.
Ejemplo n.º 8
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Animanager.  If not, see <http://www.gnu.org/licenses/>.

import argparse
import logging

from animanager.cmd import ArgumentParser, Command, compile_sql_query
from animanager.db import query
from animanager.files import AnimeFiles, find_files, is_video

logger = logging.getLogger(__name__)

parser = ArgumentParser(prog='search')
parser.add_argument(
    '-w', '--watching', action='store_true',
    help='Limit to registered anime.',
)
parser.add_argument(
    '-a', '--available', action='store_true',
    help='Limit to anime with available episodes.  Implies --watching.',
)
parser.add_argument('query', nargs=argparse.REMAINDER)

def func(cmd, args):
    """Search Animanager database."""

    where_queries = []
    params = {}
Ejemplo n.º 9
0
SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO
OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY
HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

17. Interpretation of Sections 15 and 16.

If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

See <http://www.gnu.org/licenses/gpl.html>, for more details.''')

parser = ArgumentParser(prog='gpl')
parser.add_argument('info', choices=['c', 'w'])

def func(cmd, args):
    # pylint: disable=unused-argument
    """Show GPL information.

    "gpl c" to show copying information.
    "gpl w" to show warranty information.

    """
    if args.info == 'c':
        print(GPL_COPYING)
    elif args.info == 'w':
        print(GPL_WARRANTY)
    else:
Ejemplo n.º 10
0
#
# Animanager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Animanager.  If not, see <http://www.gnu.org/licenses/>.

import time

from animanager.anidb import request_anime
from animanager.cmd import ArgumentParser, Command
from animanager.db import query

parser = ArgumentParser(prog='update')
parser.add_argument('aid', nargs='?', default=None)
parser.add_argument(
    '-i', '--incomplete', action='store_true',
    help='Update all incomplete anime.')
parser.add_argument(
    '-w', '--watching', action='store_true',
    help='Update all watching anime.')

def func(cmd, args):
    """Update an existing anime from a local database search."""
    if args.watching:
        rows = query.select.select(cmd.db, 'regexp IS NOT NULL', [], ['aid'])
        aids = [anime.aid for anime in rows]
    elif args.incomplete:
        rows = query.select.select(cmd.db, 'enddate IS NULL', [], ['aid'])
Ejemplo n.º 11
0
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Animanager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Animanager.  If not, see <http://www.gnu.org/licenses/>.

from animanager.cmd import ArgumentParser, Command
from animanager.db import query

parser = ArgumentParser(prog='unregister')

parser.add_argument(
    '-c', '--complete', action='store_true',
    help='Unregister all complete anime.')
parser.add_argument('aid', nargs='?', default=None)

def func(cmd, args):
    """Unregister watching regexp for an anime."""
    if args.complete:
        query.files.delete_regexp_complete(cmd.db)
    else:
        if args.aid is None:
            parser.print_help()
        else:
            aid = cmd.results.parse_aid(args.aid, default_key='db')