Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
Conflicts:
	flexget/plugins/output/download.py
  • Loading branch information
davidblewett committed Mar 3, 2012
2 parents 682a4ee + 7080758 commit b4653d0
Show file tree
Hide file tree
Showing 62 changed files with 599 additions and 432 deletions.
4 changes: 2 additions & 2 deletions flexget/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ def __unicode__(self):

class Entry(dict):
"""
Represents one item in feed. Must have *url* and *title* fields.
Represents one item in feed. Must have `url` and *title* fields.
Stores automatically *original_url* key, which is necessary because
plugins (eg. urlrewriters) may change *url* into something else
and otherwise that information would be lost.
Entry will also transparently convert all ascii strings into unicode
and raises :class:`EntryUnicodeError` if conversion fails on any value
being set. Such failures are catched by :class:`~flexget.feed.Feed`
being set. Such failures are caught by :class:`~flexget.feed.Feed`
and trigger :meth:`~flexget.feed.Feed.abort`.
"""

Expand Down
2 changes: 1 addition & 1 deletion flexget/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def __run_plugin(self, plugin, phase, args=None, kwargs=None):
(keyword, eue.key, eue.value))
self.abort()
except PluginError, err:
err.log.critical(err)
err.log.critical(err.value)
self.abort()
except DependencyError, e:
log.critical('Plugin `%s` cannot be used because dependency `%s` is missing.' %
Expand Down
1 change: 0 additions & 1 deletion flexget/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from sqlalchemy.pool import SingletonThreadPool
from flexget.event import fire_event
from flexget import validator
import re

log = logging.getLogger('manager')

Expand Down
2 changes: 0 additions & 2 deletions flexget/options.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import sys
from optparse import OptionParser as OptParser, SUPPRESS_HELP
import flexget
Expand Down Expand Up @@ -84,7 +83,6 @@ def __init__(self, unit_test=False, **kwargs):
self.add_option('--validate', action='store_true', dest='validate', default=False,
help=SUPPRESS_HELP)


self.add_option('--migrate', action='store', dest='migrate', default=None,
help=SUPPRESS_HELP)

Expand Down
6 changes: 3 additions & 3 deletions flexget/plugins/api_rottentomatoes.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def id_str():
movie = found.movie
if movie:
# Movie found in cache, check if cache has expired.
if movie.expired() and not only_cached:
if movie.expired and not only_cached:
log.debug('Cache has expired for %s, attempting to refresh from Rotten Tomatoes.' % id_str())
try:
get_movie_details(movie, session)
Expand Down Expand Up @@ -317,8 +317,8 @@ def id_str():
raise LookupError('No results found from rotten tomatoes for %s' % id_str())
else:
# Access attributes to force the relationships to eager load before we detach from session
movie.genres
movie.posters
for attr in ['alternate_ids', 'cast', 'directors', 'genres', 'links', 'posters', 'release_dates']:
getattr(movie, attr)
return movie


Expand Down
2 changes: 0 additions & 2 deletions flexget/plugins/cli/perf_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ def imdb_query(self, session):
import time
from flexget.plugins.metainfo.imdb_lookup import Movie
from flexget.plugins.cli.performance import log_query_count
from flexget.utils.imdb import extract_id
from sqlalchemy.sql.expression import select
from progressbar import ProgressBar, Percentage, Bar, ETA
from sqlalchemy.orm import joinedload, subqueryload
from sqlalchemy.orm import joinedload_all

imdb_urls = []
Expand Down
4 changes: 3 additions & 1 deletion flexget/plugins/cli/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def display_details(self):
print 'Unknown series `%s`' % name
return

print '%s is in identified_by `%s` mode.' % (series.name, series.identified_by or 'auto')

print ' %-63s%-15s' % ('Identifier, Title', 'Quality')
print '-' * 79

Expand All @@ -57,7 +59,7 @@ def display_details(self):
if episode.identifier is None:
print ' None <--- Broken!'
else:
print ' %s - %s' % (episode.identifier, episode.age)
print ' %s (%s) - %s' % (episode.identifier, episode.identified_by, episode.age)

for release in episode.releases:
status = release.quality.name
Expand Down
2 changes: 1 addition & 1 deletion flexget/plugins/filter/delay.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from datetime import datetime, timedelta
from datetime import datetime
from sqlalchemy import Column, Integer, String, Unicode, DateTime, PickleType, Index
from flexget import schema
from flexget.entry import Entry
Expand Down
1 change: 0 additions & 1 deletion flexget/plugins/filter/exists_movie.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import logging
from flexget.plugin import register_plugin, priority, PluginError, get_plugin_by_name
from flexget.utils.imdb import extract_id
from flexget.utils.titles.movie import MovieParser

log = logging.getLogger('exists_movie')
Expand Down
3 changes: 2 additions & 1 deletion flexget/plugins/filter/if_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

def safer_eval(statement, locals):
"""A safer eval function. Does not allow __ or try statements, only includes certain 'safe' builtins."""
allowed_builtins = ['True', 'False', 'str', 'unicode', 'int', 'float', 'len', 'any', 'all']
allowed_builtins = ['True', 'False', 'str', 'unicode', 'int', 'float', 'len', 'any', 'all', 'sorted']
for name in allowed_builtins:
locals[name] = globals()['__builtins__'].get(name)
if re.search(r'__|try\s*:', statement):
Expand Down Expand Up @@ -132,6 +132,7 @@ def handle_phase(feed, config):
feed.reject(e, e.get('reason'))
for e in fake_feed.failed:
feed.fail(e, e.get('reason'))
feed.purge()

handle_phase.priority = 80
return handle_phase
Expand Down
6 changes: 5 additions & 1 deletion flexget/plugins/filter/movie_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def matches(self, feed, config, entry):
get_plugin_by_name('tmdb_lookup').instance.lookup(entry)
except DependencyError:
log.debug('tmdb_lookup is not available, queue will not work if movie ids are not populated')
try:
get_plugin_by_name('imdb_lookup').instance.register_lazy_fields(entry)
except DependencyError:
log.debug('imdb_lookup is not available, queue will not work if movie ids are not populated')
# make sure the entry has a movie id field filled
conditions = []
# Check if a movie id is already populated before incurring a lazy lookup
Expand All @@ -67,7 +71,7 @@ def matches(self, feed, config, entry):
if conditions:
break
if not conditions:
log.warning('No movie id could be determined for %s' % entry['title'])
log.verbose('IMDB and TMDB lookups failed for %s.' % entry['title'])
return

quality = entry.get('quality', qualities.UNKNOWN)
Expand Down
23 changes: 11 additions & 12 deletions flexget/plugins/filter/private_torrents.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@

class FilterPrivateTorrents(object):
"""How to handle private torrents.
private_torrents: yes|no
Example::
private_torrents: no
This would reject all torrent entries with private flag.
Example::
private_torrents: yes
This would reject all public torrents.
Non-torrent content is not interviened.
"""

Expand All @@ -31,20 +31,19 @@ def validator(self):
@priority(127)
def on_feed_modify(self, feed):
private_torrents = feed.config['private_torrents']

rejected = False
for entry in feed.accepted:
if not 'torrent' in entry:
log.debug('`%s` is not a torrent' % entry['title'])
continue
private = entry['torrent'].private



if not private_torrents and private:
feed.reject(entry, 'torrent is marked as private', remember=True)
rejected = True
if private_torrents and not private:
feed.reject(entry, 'public torrent', remember=True)
rejected = True

register_plugin(FilterPrivateTorrents, 'private_torrents')
21 changes: 17 additions & 4 deletions flexget/plugins/filter/seen.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from flexget.plugin import register_plugin, priority, register_parser_option
from flexget import schema
from flexget.utils.sqlalchemy_utils import table_schema
from flexget.utils.imdb import extract_id
from flexget.utils.imdb import is_imdb_url, extract_id

log = logging.getLogger('seen')
Base = schema.versioned_base('seen', 2)
Expand Down Expand Up @@ -235,7 +235,14 @@ def on_process_start(self, feed):
return

feed.manager.disable_feeds()
count, fcount = forget(unicode(feed.manager.options.forget))

forget_name = unicode(feed.manager.options.forget)
if is_imdb_url(forget_name):
imdb_id = extract_id(forget_name)
if imdb_id:
forget_name = imdb_id

count, fcount = forget(forget_name)
log.info('Removed %s titles (%s fields)' % (count, fcount))


Expand All @@ -247,14 +254,20 @@ def on_process_start(self, feed):

feed.manager.disable_feeds()

seen_name = unicode(feed.manager.options.seen)
if is_imdb_url(seen_name):
imdb_id = extract_id(seen_name)
if imdb_id:
seen_name = imdb_id

session = Session()
se = SeenEntry(u'--seen', unicode(feed.name))
sf = SeenField(u'--seen', unicode(feed.manager.options.seen))
sf = SeenField(u'--seen', seen_name)
se.fields.append(sf)
session.add(se)
session.commit()

log.info('Added %s as seen. This will affect all feeds.' % feed.manager.options.seen)
log.info('Added %s as seen. This will affect all feeds.' % seen_name)


class FilterSeen(object):
Expand Down
2 changes: 1 addition & 1 deletion flexget/plugins/filter/seen_movies.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from flexget.plugins.filter.seen import FilterSeen
from flexget.plugin import register_plugin, priority, register_parser_option
from flexget.plugin import register_plugin, priority

log = logging.getLogger('seenmovies')

Expand Down
Loading

0 comments on commit b4653d0

Please sign in to comment.