I really wanted to import my Missing_TOP250.txt list into couch potato and didn't really want to do it manually as I am missing a lot. I thought about modifying the rating update script to talk to the couch potato API but realised this was way out of my league.
So instead I copied one of the couch potato automation sections and made this which when enabled in settings automation in couch potato will add the TOP250 list which rating update creates. I just used a regular expression to get the imdb ID (tt#######) and add this directly.
to install shutdown couch potato v2 (Only works with v2)
create a folder couchpotato\core\providers\automation\missingtop250
in this folder add these two files __init__.py and main.py
restart couchpotato and change your settings and enable it
once they have been imported I would disable it as there is no point running it every x hours with the other automation scripts.
enjoy
__init__.py
Code:
from .main import missingtop250
def start():
return missingtop250()
config = [{
'name': 'missingtop250',
'groups': [
{
'tab': 'automation',
'name': 'missingtop250_automation',
'label': 'Missing Top 250',
'description': 'Import the missing movies from the Missing_top250.txt created by the rating update script in xbmc. File should be the Missing_top250.txt file of one with similar formatting.',
'options': [
{
'name': 'automation_enabled',
'default': False,
'type': 'enabler',
},
{
'name': 'directory',
'type': 'directory',
'description': 'Directory where the missing top 250 file is saved to.',
},
{
'name': 'filename',
'default': '',
'description': 'Name of the missing top 250 file.',
},
],
},
],
}]
and main.py
Code:
from couchpotato.core.helpers.rss import RSS
from couchpotato.core.helpers.variable import md5, getImdb
from couchpotato.core.logger import CPLog
from couchpotato.core.providers.automation.base import Automation
from couchpotato.environment import Env
from dateutil.parser import parse
import time
import traceback
import xml.etree.ElementTree as XMLTree
import os, fileinput, re
log = CPLog(__name__)
class missingtop250(Automation, RSS):
interval = 1800
def getIMDBids(self):
if self.isDisabled():
return
movies = []
directory = self.conf('directory')
filename = self.conf('filename')
if not directory or not os.path.isdir(directory):
log.error('No directory set for missing top 250 download or incorrect.')
elif not filename or not os.path.isfile(os.path.join(directory, filename)):
log.error('No filename set for missing top 250 download or incorrect.')
else:
uploaded_file = os.path.join(directory, filename)
try:
topFile = open(uploaded_file)
for line in topFile:
match = re.match('.*(tt\d+).*$', line)
if match:
imdb = match.group(1)
if getImdb(imdb):
movies.append(imdb)
log.error('Movie added from Missing Top 250: %s', imdb)
topFile.close()
except:
log.error('Failed to open %s: %s', uploaded_file, traceback.format_exc())
return movies