Move plugins to single file

This commit is contained in:
Ruud
2014-03-11 22:47:42 +01:00
parent 8492c9b214
commit 0b61ec1e13
28 changed files with 345 additions and 403 deletions

View File

@@ -1,8 +1,55 @@
from .main import Automation
from couchpotato.core.event import addEvent, fireEvent
from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env
log = CPLog(__name__)
autoload = 'Automation'
def start():
return Automation()
class Automation(Plugin):
def __init__(self):
addEvent('app.load', self.setCrons)
if not Env.get('dev'):
addEvent('app.load', self.addMovies)
addEvent('setting.save.automation.hour.after', self.setCrons)
def setCrons(self):
fireEvent('schedule.interval', 'automation.add_movies', self.addMovies, hours = self.conf('hour', default = 12))
def addMovies(self):
movies = fireEvent('automation.get_movies', merge = True)
movie_ids = []
for imdb_id in movies:
if self.shuttingDown():
break
prop_name = 'automation.added.%s' % imdb_id
added = Env.prop(prop_name, default = False)
if not added:
added_movie = fireEvent('movie.add', params = {'identifier': imdb_id}, force_readd = False, search_after = False, update_library = True, single = True)
if added_movie:
movie_ids.append(added_movie['id'])
Env.prop(prop_name, True)
for movie_id in movie_ids:
if self.shuttingDown():
break
movie_dict = fireEvent('media.get', movie_id, single = True)
fireEvent('movie.searcher.single', movie_dict)
return True
config = [{
'name': 'automation',

View File

@@ -1,49 +0,0 @@
from couchpotato.core.event import addEvent, fireEvent
from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env
log = CPLog(__name__)
class Automation(Plugin):
def __init__(self):
addEvent('app.load', self.setCrons)
if not Env.get('dev'):
addEvent('app.load', self.addMovies)
addEvent('setting.save.automation.hour.after', self.setCrons)
def setCrons(self):
fireEvent('schedule.interval', 'automation.add_movies', self.addMovies, hours = self.conf('hour', default = 12))
def addMovies(self):
movies = fireEvent('automation.get_movies', merge = True)
movie_ids = []
for imdb_id in movies:
if self.shuttingDown():
break
prop_name = 'automation.added.%s' % imdb_id
added = Env.prop(prop_name, default = False)
if not added:
added_movie = fireEvent('movie.add', params = {'identifier': imdb_id}, force_readd = False, search_after = False, update_library = True, single = True)
if added_movie:
movie_ids.append(added_movie['id'])
Env.prop(prop_name, True)
for movie_id in movie_ids:
if self.shuttingDown():
break
movie_dict = fireEvent('media.get', movie_id, single = True)
fireEvent('movie.searcher.single', movie_dict)
return True

View File

@@ -17,6 +17,9 @@ if os.name == 'nt':
else:
import win32file #@UnresolvedImport
autoload = 'FileBrowser'
class FileBrowser(Plugin):
def __init__(self):

View File

@@ -1,7 +0,0 @@
from .main import FileBrowser
def start():
return FileBrowser()
config = []

View File

@@ -1,7 +1,5 @@
from .main import CategoryPlugin
def start():
def autoload():
return CategoryPlugin()
config = []

View File

@@ -6,6 +6,8 @@ import os
log = CPLog(__name__)
autoload = 'Custom'
class Custom(Plugin):

View File

@@ -1,7 +0,0 @@
from .main import Custom
def start():
return Custom()
config = []

View File

@@ -10,6 +10,8 @@ import time
log = CPLog(__name__)
autoload = 'Dashboard'
class Dashboard(Plugin):

View File

@@ -1,7 +0,0 @@
from .main import Dashboard
def start():
return Dashboard()
config = []

View File

@@ -14,6 +14,8 @@ import traceback
log = CPLog(__name__)
autoload = 'FileManager'
class FileManager(Plugin):

View File

@@ -1,7 +0,0 @@
from .main import FileManager
def start():
return FileManager()
config = []

View File

@@ -1,7 +1,5 @@
from .main import Logging
def start():
def autoload():
return Logging()
config = []

View File

@@ -12,9 +12,10 @@ import sys
import time
import traceback
log = CPLog(__name__)
autoload = 'Manage'
class Manage(Plugin):
@@ -268,3 +269,41 @@ class Manage(Plugin):
return free_space
config = [{
'name': 'manage',
'groups': [
{
'tab': 'manage',
'label': 'Movie Library Manager',
'description': 'Add your existing movie folders.',
'options': [
{
'name': 'enabled',
'default': False,
'type': 'enabler',
},
{
'name': 'library',
'type': 'directories',
'description': 'Folder where the movies should be moved to.',
},
{
'label': 'Cleanup After',
'name': 'cleanup',
'type': 'bool',
'description': 'Remove movie from db if it can\'t be found after re-scan.',
'default': True,
},
{
'label': 'Scan at startup',
'name': 'startup_scan',
'type': 'bool',
'default': True,
'advanced': True,
'description': 'Do a quick scan on startup. On slow systems better disable this.',
},
],
},
],
}]

View File

@@ -1,43 +0,0 @@
from .main import Manage
def start():
return Manage()
config = [{
'name': 'manage',
'groups': [
{
'tab': 'manage',
'label': 'Movie Library Manager',
'description': 'Add your existing movie folders.',
'options': [
{
'name': 'enabled',
'default': False,
'type': 'enabler',
},
{
'name': 'library',
'type': 'directories',
'description': 'Folder where the movies should be moved to.',
},
{
'label': 'Cleanup After',
'name': 'cleanup',
'type': 'bool',
'description': 'Remove movie from db if it can\'t be found after re-scan.',
'default': True,
},
{
'label': 'Scan at startup',
'name': 'startup_scan',
'type': 'bool',
'default': True,
'advanced': True,
'description': 'Do a quick scan on startup. On slow systems better disable this.',
},
],
},
],
}]

View File

@@ -1,7 +1,5 @@
from .main import ProfilePlugin
def start():
def autoload():
return ProfilePlugin()
config = []

View File

@@ -1,7 +1,7 @@
from .main import QualityPlugin
def start():
def autoload():
return QualityPlugin()
config = []

View File

@@ -1,7 +1,5 @@
from .main import Release
def start():
def autoload():
return Release()
config = []

View File

@@ -9,7 +9,6 @@ from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env
from scandir import scandir
from unrar2 import RarFile
import errno
import fnmatch
import os
import re
@@ -21,6 +20,8 @@ from six.moves import filter
log = CPLog(__name__)
autoload = 'Renamer'
class Renamer(Plugin):
@@ -1187,3 +1188,176 @@ Remove it if you want it to be renamed (again, or at least let it try again)
folder = None
return folder, media_folder, files, extr_files
rename_options = {
'pre': '<',
'post': '>',
'choices': {
'ext': 'Extention (mkv)',
'namethe': 'Moviename, The',
'thename': 'The Moviename',
'year': 'Year (2011)',
'first': 'First letter (M)',
'quality': 'Quality (720p)',
'quality_type': '(HD) or (SD)',
'video': 'Video (x264)',
'audio': 'Audio (DTS)',
'group': 'Releasegroup name',
'source': 'Source media (Bluray)',
'resolution_width': 'resolution width (1280)',
'resolution_height': 'resolution height (720)',
'audio_channels': 'audio channels (7.1)',
'original': 'Original filename',
'original_folder': 'Original foldername',
'imdb_id': 'IMDB id (tt0123456)',
'cd': 'CD number (cd1)',
'cd_nr': 'Just the cd nr. (1)',
'mpaa': 'MPAA Rating',
'category': 'Category label',
},
}
config = [{
'name': 'renamer',
'order': 40,
'description': 'Move and rename your downloaded movies to your movie directory.',
'groups': [
{
'tab': 'renamer',
'name': 'renamer',
'label': 'Rename downloaded movies',
'wizard': True,
'options': [
{
'name': 'enabled',
'default': False,
'type': 'enabler',
},
{
'name': 'from',
'type': 'directory',
'description': 'Folder where CP searches for movies.',
},
{
'name': 'to',
'type': 'directory',
'description': 'Default folder where the movies are moved to.',
},
{
'name': 'folder_name',
'label': 'Folder naming',
'description': 'Name of the folder. Keep empty for no folder.',
'default': '<namethe> (<year>)',
'type': 'choice',
'options': rename_options
},
{
'name': 'file_name',
'label': 'File naming',
'description': 'Name of the file',
'default': '<thename><cd>.<ext>',
'type': 'choice',
'options': rename_options
},
{
'name': 'unrar',
'type': 'bool',
'description': 'Extract rar files if found.',
'default': False,
},
{
'name': 'cleanup',
'type': 'bool',
'description': 'Cleanup leftover files after successful rename.',
'default': False,
},
{
'advanced': True,
'name': 'run_every',
'label': 'Run every',
'default': 1,
'type': 'int',
'unit': 'min(s)',
'description': ('Detect movie status every X minutes.', 'Will start the renamer if movie is <strong>completed</strong> or handle <strong>failed</strong> download if these options are enabled'),
},
{
'advanced': True,
'name': 'force_every',
'label': 'Force every',
'default': 2,
'type': 'int',
'unit': 'hour(s)',
'description': 'Forces the renamer to scan every X hours',
},
{
'advanced': True,
'name': 'next_on_failed',
'default': True,
'type': 'bool',
'description': 'Try the next best release for a movie after a download failed.',
},
{
'name': 'move_leftover',
'type': 'bool',
'description': 'Move all leftover file after renaming, to the movie folder.',
'default': False,
'advanced': True,
},
{
'advanced': True,
'name': 'separator',
'label': 'File-Separator',
'description': ('Replace all the spaces with a character.', 'Example: ".", "-" (without quotes). Leave empty to use spaces.'),
},
{
'advanced': True,
'name': 'foldersep',
'label': 'Folder-Separator',
'description': ('Replace all the spaces with a character.', 'Example: ".", "-" (without quotes). Leave empty to use spaces.'),
},
{
'name': 'file_action',
'label': 'Torrent File Action',
'default': 'link',
'type': 'dropdown',
'values': [('Link', 'link'), ('Copy', 'copy'), ('Move', 'move')],
'description': ('<strong>Link</strong>, <strong>Copy</strong> or <strong>Move</strong> after download completed.',
'Link first tries <a href="http://en.wikipedia.org/wiki/Hard_link">hard link</a>, then <a href="http://en.wikipedia.org/wiki/Sym_link">sym link</a> and falls back to Copy. It is perfered to use link when downloading torrents as it will save you space, while still beeing able to seed.'),
'advanced': True,
},
{
'advanced': True,
'name': 'ntfs_permission',
'label': 'NTFS Permission',
'type': 'bool',
'hidden': os.name != 'nt',
'description': 'Set permission of moved files to that of destination folder (Windows NTFS only).',
'default': False,
},
],
}, {
'tab': 'renamer',
'name': 'meta_renamer',
'label': 'Advanced renaming',
'description': 'Meta data file renaming. Use &lt;filename&gt; to use the above "File naming" settings, without the file extention.',
'advanced': True,
'options': [
{
'name': 'rename_nfo',
'label': 'Rename .NFO',
'description': 'Rename original .nfo file',
'type': 'bool',
'default': True,
},
{
'name': 'nfo_name',
'label': 'NFO naming',
'default': '<filename>.orig.<ext>',
'type': 'choice',
'options': rename_options
},
],
},
],
}]

View File

@@ -1,178 +0,0 @@
from couchpotato.core.plugins.renamer.main import Renamer
import os
def start():
return Renamer()
rename_options = {
'pre': '<',
'post': '>',
'choices': {
'ext': 'Extention (mkv)',
'namethe': 'Moviename, The',
'thename': 'The Moviename',
'year': 'Year (2011)',
'first': 'First letter (M)',
'quality': 'Quality (720p)',
'quality_type': '(HD) or (SD)',
'video': 'Video (x264)',
'audio': 'Audio (DTS)',
'group': 'Releasegroup name',
'source': 'Source media (Bluray)',
'resolution_width': 'resolution width (1280)',
'resolution_height': 'resolution height (720)',
'audio_channels': 'audio channels (7.1)',
'original': 'Original filename',
'original_folder': 'Original foldername',
'imdb_id': 'IMDB id (tt0123456)',
'cd': 'CD number (cd1)',
'cd_nr': 'Just the cd nr. (1)',
'mpaa': 'MPAA Rating',
'category': 'Category label',
},
}
config = [{
'name': 'renamer',
'order': 40,
'description': 'Move and rename your downloaded movies to your movie directory.',
'groups': [
{
'tab': 'renamer',
'name': 'renamer',
'label': 'Rename downloaded movies',
'wizard': True,
'options': [
{
'name': 'enabled',
'default': False,
'type': 'enabler',
},
{
'name': 'from',
'type': 'directory',
'description': 'Folder where CP searches for movies.',
},
{
'name': 'to',
'type': 'directory',
'description': 'Default folder where the movies are moved to.',
},
{
'name': 'folder_name',
'label': 'Folder naming',
'description': 'Name of the folder. Keep empty for no folder.',
'default': '<namethe> (<year>)',
'type': 'choice',
'options': rename_options
},
{
'name': 'file_name',
'label': 'File naming',
'description': 'Name of the file',
'default': '<thename><cd>.<ext>',
'type': 'choice',
'options': rename_options
},
{
'name': 'unrar',
'type': 'bool',
'description': 'Extract rar files if found.',
'default': False,
},
{
'name': 'cleanup',
'type': 'bool',
'description': 'Cleanup leftover files after successful rename.',
'default': False,
},
{
'advanced': True,
'name': 'run_every',
'label': 'Run every',
'default': 1,
'type': 'int',
'unit': 'min(s)',
'description': ('Detect movie status every X minutes.', 'Will start the renamer if movie is <strong>completed</strong> or handle <strong>failed</strong> download if these options are enabled'),
},
{
'advanced': True,
'name': 'force_every',
'label': 'Force every',
'default': 2,
'type': 'int',
'unit': 'hour(s)',
'description': 'Forces the renamer to scan every X hours',
},
{
'advanced': True,
'name': 'next_on_failed',
'default': True,
'type': 'bool',
'description': 'Try the next best release for a movie after a download failed.',
},
{
'name': 'move_leftover',
'type': 'bool',
'description': 'Move all leftover file after renaming, to the movie folder.',
'default': False,
'advanced': True,
},
{
'advanced': True,
'name': 'separator',
'label': 'File-Separator',
'description': ('Replace all the spaces with a character.', 'Example: ".", "-" (without quotes). Leave empty to use spaces.'),
},
{
'advanced': True,
'name': 'foldersep',
'label': 'Folder-Separator',
'description': ('Replace all the spaces with a character.', 'Example: ".", "-" (without quotes). Leave empty to use spaces.'),
},
{
'name': 'file_action',
'label': 'Torrent File Action',
'default': 'link',
'type': 'dropdown',
'values': [('Link', 'link'), ('Copy', 'copy'), ('Move', 'move')],
'description': ('<strong>Link</strong>, <strong>Copy</strong> or <strong>Move</strong> after download completed.',
'Link first tries <a href="http://en.wikipedia.org/wiki/Hard_link">hard link</a>, then <a href="http://en.wikipedia.org/wiki/Sym_link">sym link</a> and falls back to Copy. It is perfered to use link when downloading torrents as it will save you space, while still beeing able to seed.'),
'advanced': True,
},
{
'advanced': True,
'name': 'ntfs_permission',
'label': 'NTFS Permission',
'type': 'bool',
'hidden': os.name != 'nt',
'description': 'Set permission of moved files to that of destination folder (Windows NTFS only).',
'default': False,
},
],
}, {
'tab': 'renamer',
'name': 'meta_renamer',
'label': 'Advanced renaming',
'description': 'Meta data file renaming. Use &lt;filename&gt; to use the above "File naming" settings, without the file extention.',
'advanced': True,
'options': [
{
'name': 'rename_nfo',
'label': 'Rename .NFO',
'description': 'Rename original .nfo file',
'type': 'bool',
'default': True,
},
{
'name': 'nfo_name',
'label': 'NFO naming',
'default': '<filename>.orig.<ext>',
'type': 'choice',
'options': rename_options
},
],
},
],
}]

View File

@@ -1,7 +0,0 @@
from .main import Scanner
def start():
return Scanner()
config = []

View File

@@ -1,7 +1,5 @@
from .main import Score
def start():
def autoload():
return Score()
config = []

View File

@@ -9,6 +9,8 @@ import traceback
log = CPLog(__name__)
autoload = 'Subtitle'
class Subtitle(Plugin):
@@ -47,3 +49,28 @@ class Subtitle(Plugin):
def getLanguages(self):
return splitString(self.conf('languages'))
config = [{
'name': 'subtitle',
'groups': [
{
'tab': 'renamer',
'name': 'subtitle',
'label': 'Download subtitles',
'description': 'after rename',
'options': [
{
'name': 'enabled',
'label': 'Search and download subtitles',
'default': False,
'type': 'enabler',
},
{
'name': 'languages',
'description': ('Comma separated, 2 letter country code.', 'Example: en, nl. See the codes at <a href="http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes">on Wikipedia</a>'),
},
],
},
],
}]

View File

@@ -1,35 +0,0 @@
from .main import Subtitle
def start():
return Subtitle()
config = [{
'name': 'subtitle',
'groups': [
{
'tab': 'renamer',
'name': 'subtitle',
'label': 'Download subtitles',
'description': 'after rename',
'options': [
{
'name': 'enabled',
'label': 'Search and download subtitles',
'default': False,
'type': 'enabler',
},
{
'name': 'languages',
'description': ('Comma separated, 2 letter country code.', 'Example: en, nl. See the codes at <a href="http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes">on Wikipedia</a>'),
},
# {
# 'name': 'automatic',
# 'default': True,
# 'type': 'bool',
# 'description': 'Automaticly search & download for movies in library',
# },
],
},
],
}]

View File

@@ -6,6 +6,8 @@ import os
log = CPLog(__name__)
autoload = 'Trailer'
class Trailer(Plugin):
@@ -40,3 +42,37 @@ class Trailer(Plugin):
break
return True
config = [{
'name': 'trailer',
'groups': [
{
'tab': 'renamer',
'name': 'trailer',
'label': 'Download trailer',
'description': 'after rename',
'options': [
{
'name': 'enabled',
'label': 'Search and download trailers',
'default': False,
'type': 'enabler',
},
{
'name': 'quality',
'default': '720p',
'type': 'dropdown',
'values': [('1080p', '1080p'), ('720p', '720p'), ('480P', '480p')],
},
{
'name': 'name',
'label': 'Naming',
'default': '<filename>-trailer',
'advanced': True,
'description': 'Use <strong>&lt;filename&gt;</strong> to use above settings.'
},
],
},
],
}]

View File

@@ -1,38 +0,0 @@
from .main import Trailer
def start():
return Trailer()
config = [{
'name': 'trailer',
'groups': [
{
'tab': 'renamer',
'name': 'trailer',
'label': 'Download trailer',
'description': 'after rename',
'options': [
{
'name': 'enabled',
'label': 'Search and download trailers',
'default': False,
'type': 'enabler',
},
{
'name': 'quality',
'default': '720p',
'type': 'dropdown',
'values': [('1080p', '1080p'), ('720p', '720p'), ('480P', '480p')],
},
{
'name': 'name',
'label': 'Naming',
'default': '<filename>-trailer',
'advanced': True,
'description': 'Use <strong>&lt;filename&gt;</strong> to use above settings.'
},
],
},
],
}]

View File

@@ -1,7 +1,5 @@
from .main import Userscript
def start():
def autoload():
return Userscript()
config = []

View File

@@ -1,7 +1,7 @@
from .main import Wizard
def start():
def autoload():
return Wizard()
config = [{