forked from 05sonicblue/Gamez
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Settings Page. Added upcoming releases page. Changed Background…
… Task to monitor in order for scheduled tasks to work with daemon mode.
- Loading branch information
Michael Dlesk
committed
Jan 11, 2012
1 parent
5456be9
commit 16cd36a
Showing
73 changed files
with
2,044 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ port = | |
api_key = "" | ||
host = "127.0.0.1" | ||
port = 8081 | ||
category = "" | ||
|
||
[Scheduler] | ||
download_interval = 60 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
from app.config.cplog import CPLog | ||
from app.lib.cron.eta import startEtaCron, etaQueue | ||
from app.lib.cron.renamer import startRenamerCron | ||
from app.lib.cron.movierss import startMovieRSSCron | ||
from app.lib.cron.kinepolisrss import startKinepolisRSSCron | ||
from app.lib.cron.trakt import startTraktCron | ||
from app.lib.cron.subtitle import subtitleQueue, startSubtitleCron | ||
from app.lib.cron.trailer import startTrailerCron, trailerQueue | ||
from app.lib.cron.yarr import startYarrCron | ||
from app.lib.provider.movie.search import movieSearcher | ||
from app.lib.provider.yarr.search import Searcher | ||
from app.lib.sabNzbd import sabNzbd | ||
from app.lib.nzbget import nzbGet | ||
from app.lib.transmission import transmission | ||
from cherrypy.process import plugins | ||
import cherrypy | ||
import sys | ||
|
||
log = CPLog(__name__) | ||
|
||
class CronJobs(plugins.SimplePlugin): | ||
|
||
config = {} | ||
threads = {} | ||
searchers = {} | ||
|
||
def __init__(self, bus, config, debug): | ||
plugins.SimplePlugin.__init__(self, bus) | ||
|
||
self.config = config | ||
self.debug = debug | ||
|
||
def start(self): | ||
|
||
config = self.config | ||
|
||
log.info("Starting Cronjobs.") | ||
self.config = config | ||
|
||
#searchers | ||
yarrSearch = Searcher(config, self.debug); | ||
movieSearch = movieSearcher(config); | ||
self.searchers['yarr'] = yarrSearch | ||
self.searchers['movie'] = movieSearch | ||
|
||
#trailer cron | ||
trailerCronJob = startTrailerCron(config, self.debug) | ||
self.threads['trailer'] = trailerCronJob | ||
self.searchers['trailerQueue'] = trailerQueue | ||
|
||
#subtitle cron | ||
subtitleCronJob = startSubtitleCron(config, self.debug) | ||
self.threads['subtitle'] = subtitleCronJob | ||
self.searchers['subtitleQueue'] = subtitleQueue | ||
|
||
etaCron = startEtaCron(config, self.debug) | ||
self.threads['eta'] = etaCron | ||
self.searchers['etaQueue'] = etaQueue | ||
|
||
#renamer cron | ||
renamerCronJob = startRenamerCron(config, self.searchers, self.debug) | ||
self.threads['renamer'] = renamerCronJob | ||
|
||
#Movie RSS cron | ||
MovieRSSCronJob = startMovieRSSCron(config, self.searchers, self.debug) | ||
self.threads['MovieRSS'] = MovieRSSCronJob | ||
|
||
#Kinepolis RSS cron | ||
KinepolisRSSCronJob = startKinepolisRSSCron(config, self.searchers, self.debug) | ||
self.threads['KinepolisRSS'] = KinepolisRSSCronJob | ||
|
||
#Trakt cron | ||
TraktCronJob = startTraktCron(config, self.searchers, self.debug) | ||
self.threads['Trakt'] = TraktCronJob | ||
|
||
#nzb cronjob | ||
yarrCronJob = startYarrCron(config, self.debug, yarrSearch) | ||
yarrCronJob.sabNzbd = sabNzbd(config) | ||
yarrCronJob.transmission = transmission(config) | ||
yarrCronJob.nzbGet = nzbGet(config) | ||
self.threads['yarr'] = yarrCronJob | ||
|
||
#log all errors/tracebacks to logfile | ||
#sys.stderr = LogFile('stderr') | ||
|
||
def stop(self): | ||
log.info("Stopping Cronjobs.") | ||
for t in self.threads.itervalues(): | ||
if t.quit: | ||
t.quit() | ||
t.join() | ||
|
||
start.priority = 70 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import threading | ||
|
||
class cronBase(threading.Thread): | ||
|
||
abort = False | ||
running = False | ||
debug = False | ||
|
||
def isRunning(self): | ||
return self.running | ||
|
||
def quit(self): | ||
self.abort = True | ||
|
||
def canShutdown(self): | ||
return (self.abort and not self.running) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
from app.config.cplog import CPLog | ||
from app.config.db import Movie, MovieETA, Session as Db | ||
from app.lib.cron.base import cronBase | ||
from app.lib.provider.rss import rss | ||
from dateutil.parser import parse | ||
from sqlalchemy.sql.expression import or_ | ||
from urllib import urlencode | ||
import Queue | ||
import cherrypy | ||
import time | ||
import json | ||
|
||
etaQueue = Queue.Queue() | ||
log = CPLog(__name__) | ||
|
||
class etaCron(rss, cronBase): | ||
|
||
apiUrl = 'http://couchpotatoapp.com/api/eta/%s/' | ||
|
||
def conf(self, option): | ||
return self.config.get('RottenTomatoes', option) | ||
|
||
def run(self): | ||
log.info('ETA thread is running.') | ||
|
||
timeout = 0.1 if self.debug else 1 | ||
while True and not self.abort: | ||
|
||
try: | ||
queue = etaQueue.get(timeout = timeout) | ||
if queue.get('id'): | ||
movie = Db.query(Movie).filter_by(id = queue.get('id')).first() | ||
else: | ||
movie = queue.get('movie') | ||
|
||
if not cherrypy.config.get('debug'): | ||
#do a search | ||
self.running = True | ||
result = self.search(movie) | ||
if result: | ||
self.save(movie, result) | ||
self.running = False | ||
|
||
etaQueue.task_done() | ||
time.sleep(timeout) | ||
except Queue.Empty: | ||
pass | ||
|
||
log.info('ETA thread shutting down.') | ||
|
||
def all(self): | ||
activeMovies = Db.query(Movie).filter(or_(Movie.status == u'want', Movie.status == u'waiting')).all() | ||
for movie in activeMovies: | ||
etaQueue.put({'movie':movie}) | ||
|
||
def save(self, movie, result): | ||
|
||
row = Db.query(MovieETA).filter_by(movieId = movie.id).first() | ||
if not row: | ||
row = MovieETA() | ||
Db.add(row) | ||
|
||
row.movieId = movie.id | ||
row.theater = result.get('theater') | ||
row.dvd = result.get('dvd') | ||
row.bluray = result.get('bluray') | ||
row.lastCheck = result.get('expires') | ||
Db.flush() | ||
|
||
def search(self, movie, page = 1): | ||
|
||
# Already found it, just update the stuff | ||
if movie.imdb: | ||
log.debug('Updating VideoETA for %s.' % movie.name) | ||
return self.getDetails(movie.imdb) | ||
|
||
log.info('No IMDBid available for ETA searching') | ||
|
||
def getDetails(self, id): | ||
|
||
url = self.apiUrl % id | ||
|
||
try: | ||
data = self.urlopen(url).read() | ||
except: | ||
log.error('Failed to open %s.' % url) | ||
return False | ||
|
||
try: | ||
dates = json.loads(data) | ||
log.info('Found ETA: %s' % dates) | ||
except: | ||
log.error('Error getting ETA for %s' % id) | ||
|
||
return dates | ||
|
||
|
||
def startEtaCron(config, debug): | ||
c = etaCron() | ||
c.config = config | ||
c.debug = debug | ||
c.start() | ||
|
||
return c |
Binary file not shown.
Oops, something went wrong.