Browse Source

Move plugins to single file

pull/3111/head
Ruud 11 years ago
parent
commit
0b61ec1e13
  1. 53
      couchpotato/core/plugins/automation.py
  2. 49
      couchpotato/core/plugins/automation/main.py
  3. 3
      couchpotato/core/plugins/browser.py
  4. 7
      couchpotato/core/plugins/browser/__init__.py
  5. 4
      couchpotato/core/plugins/category/__init__.py
  6. 2
      couchpotato/core/plugins/custom.py
  7. 7
      couchpotato/core/plugins/custom/__init__.py
  8. 2
      couchpotato/core/plugins/dashboard.py
  9. 7
      couchpotato/core/plugins/dashboard/__init__.py
  10. 2
      couchpotato/core/plugins/file.py
  11. 7
      couchpotato/core/plugins/file/__init__.py
  12. 4
      couchpotato/core/plugins/log/__init__.py
  13. 41
      couchpotato/core/plugins/manage.py
  14. 43
      couchpotato/core/plugins/manage/__init__.py
  15. 4
      couchpotato/core/plugins/profile/__init__.py
  16. 2
      couchpotato/core/plugins/quality/__init__.py
  17. 4
      couchpotato/core/plugins/release/__init__.py
  18. 176
      couchpotato/core/plugins/renamer.py
  19. 178
      couchpotato/core/plugins/renamer/__init__.py
  20. 0
      couchpotato/core/plugins/scanner.py
  21. 7
      couchpotato/core/plugins/scanner/__init__.py
  22. 4
      couchpotato/core/plugins/score/__init__.py
  23. 27
      couchpotato/core/plugins/subtitle.py
  24. 35
      couchpotato/core/plugins/subtitle/__init__.py
  25. 36
      couchpotato/core/plugins/trailer.py
  26. 38
      couchpotato/core/plugins/trailer/__init__.py
  27. 4
      couchpotato/core/plugins/userscript/__init__.py
  28. 2
      couchpotato/core/plugins/wizard/__init__.py

53
couchpotato/core/plugins/automation/__init__.py → couchpotato/core/plugins/automation.py

@ -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'
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
def start():
return Automation()
config = [{
'name': 'automation',

49
couchpotato/core/plugins/automation/main.py

@ -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

3
couchpotato/core/plugins/browser/main.py → couchpotato/core/plugins/browser.py

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

7
couchpotato/core/plugins/browser/__init__.py

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

4
couchpotato/core/plugins/category/__init__.py

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

2
couchpotato/core/plugins/custom/main.py → couchpotato/core/plugins/custom.py

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

7
couchpotato/core/plugins/custom/__init__.py

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

2
couchpotato/core/plugins/dashboard/main.py → couchpotato/core/plugins/dashboard.py

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

7
couchpotato/core/plugins/dashboard/__init__.py

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

2
couchpotato/core/plugins/file/main.py → couchpotato/core/plugins/file.py

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

7
couchpotato/core/plugins/file/__init__.py

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

4
couchpotato/core/plugins/log/__init__.py

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

41
couchpotato/core/plugins/manage/main.py → couchpotato/core/plugins/manage.py

@ -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.',
},
],
},
],
}]

43
couchpotato/core/plugins/manage/__init__.py

@ -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.',
},
],
},
],
}]

4
couchpotato/core/plugins/profile/__init__.py

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

2
couchpotato/core/plugins/quality/__init__.py

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

4
couchpotato/core/plugins/release/__init__.py

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

176
couchpotato/core/plugins/renamer/main.py → couchpotato/core/plugins/renamer.py

@ -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
},
],
},
],
}]

178
couchpotato/core/plugins/renamer/__init__.py

@ -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
},
],
},
],
}]

0
couchpotato/core/plugins/scanner/main.py → couchpotato/core/plugins/scanner.py

7
couchpotato/core/plugins/scanner/__init__.py

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

4
couchpotato/core/plugins/score/__init__.py

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

27
couchpotato/core/plugins/subtitle/main.py → couchpotato/core/plugins/subtitle.py

@ -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>'),
},
],
},
],
}]

35
couchpotato/core/plugins/subtitle/__init__.py

@ -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',
# },
],
},
],
}]

36
couchpotato/core/plugins/trailer/main.py → couchpotato/core/plugins/trailer.py

@ -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.'
},
],
},
],
}]

38
couchpotato/core/plugins/trailer/__init__.py

@ -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.'
},
],
},
],
}]

4
couchpotato/core/plugins/userscript/__init__.py

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

2
couchpotato/core/plugins/wizard/__init__.py

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

Loading…
Cancel
Save