Torrenting utils, mostly for handling bencoding and torrent files.
Bases: object
Represents a torrent
alias of str
Appends multi-tracker to this torrent
Create torrent from file on disk.
Return array containing fileinfo dictionaries (name, length, path)
Return Torrent info hash
Return array containing all multi-trackers in this torrent. Returns empty array if torrent has only standard single announce url.
Return total size of the torrent
Removes passed multi-tracker from this torrent
Clean meta dict. Optionally log changes using the given logger.
See also http://packages.python.org/pyrocore/apidocs/pyrocore.util.metafile-pysrc.html#clean_meta
@param logger: If given, a callable accepting a string message. @return: Set of keys removed from C{meta}.
Check whether a file looks like a metafile by peeking into its content.
Note that this doesn’t ensure that the file is a complete and valid torrent, it just allows fast filtering of candidate files.
@param metafilepath: Path to the file to check, must have read permissions for it. @return: True if there is a high probability this is a metafile.
Bases: sqlalchemy.ext.declarative.Base
Bases: sqlalchemy.ext.declarative.Base
Bases: object
Implements transparent caching decorator @cached for inputs.
Decorator has two parameters:
Note
Configuration assumptions may make this unusable in some (future) inputs
Clears the input cache before execution. This is neccessary for webui or otherwise it will only use cache.
| Parameters: | config (dict) – Configuration |
|---|---|
| Returns: | MD5 hash for config |
Removes old input caches from plugins that are no longer configured.
Bases: sqlalchemy.ext.hybrid.Comparator
Hybrid value representing a string that compares case insensitively.
Bases: sqlalchemy.ext.hybrid.Comparator
Database quality comparator fields which can operate against quality objects or their string equivalents.
Converts pipe separated text into a list
Used to store Entry instances into a PickleType column in the database.
In order to ensure everything can be loaded after code changes, makes sure no custom python classes are pickled.
Converts Y-M-D date strings into datetime objects
” A decorator which creates a new session if one was not passed via keyword argument to the function.
Automatically commits and closes the session if one was created, caller is responsible for commit if passed in.
Bases: object
Quick-hack to parse relevant imdb details
Bases: object
Return single movie that best matches name criteria or None
Case insensitive string replace
Return array of movie details (dict)
Accepts messy name, cleans it and uses information available to make smartest and best match
Return IMDb ID of the given URL. Return None if not valid or if URL is not a string.
Return IMDb URL of the given ID
Logging utilities
Bases: sqlalchemy.ext.declarative.Base
Declarative
Log message only once using given logger. Returns False if suppressed logging. When suppressed verbose level is still logged.
Purge old messages from database
Warning
Many methods in this module are not thread safe since they do in place sort for qualities
Bases: object
Test if quality matches to text.
| Parameters: | text (string) – data te be tested against |
|---|---|
| Returns: | tuple (matches, remaining text without quality data) |
Return all Qualities in order of best to worst
Return common name for name (case insensitive).
| Parameters: | name (string) – Name to be converted in the common form. |
|---|---|
| Returns: | common name, eg. 1280x720, 720 and 720p will all return 720p |
| Return type: | string |
Return Quality object for :name: (case insensitive) :param name: Quality name :return: Found Quality / UNKNOWN or default if given and nothing was found.
Return highest known Quality.
Return lowest known Quality excluding unknown.
Find the highest know quality in a given string :title:
| Returns: | Quality object or False |
|---|
Search best quality from title
| Parameters: | title (string) – text to search from |
|---|---|
| Returns: | tuple (Quality which can be unknown, remaining title without quality) |
| Parameters: | name (str) – case insensitive quality name |
|---|---|
| Returns: | Return value of quality with given name or 0 if unknown |
Bases: requests.sessions.Session
Subclass of requests Session class which defines some of our own defaults, records unresponsive sites, and raises errors by default.
Add a CookieJar whose cookies will apply to this session. If the session already has a cookiejar set, the cookies will be merged together.
| Parameters: | cookiejar – CookieJar instance to add to the session. |
|---|
Does a request, but raises Timeout immediately if site is known to timeout, and records sites that timeout. Also raises errors getting the content by default.
Registers a minimum interval between requests to domain
| Parameters: |
|
|---|
Returns a dict containing the cookies from cookiejar that apply to given url.
| Parameters: |
|
|---|---|
| Returns: | A dict with cookies that apply to given url. |
| Return type: | dict |
Sends a GET request. Returns Response object.
| Parameters: |
|
|---|
Checks if host of given url has timed out within WAIT_TIME
| Parameters: | url – The url to check |
|---|---|
| Returns: | True if the host has timed out within WAIT_TIME |
| Return type: | bool |
Sends a POST request. Returns Response object.
| Parameters: |
|
|---|
Marks the host of a given url as unresponsive
| Parameters: | url – The url that timed out |
|---|
Common tools used by plugins implementing search plugin api
Bases: object
Comparator that does no comparison. Used to return all results from a search plugin without filtering.
Return a cleaned string based on seq1 that can be used for searching.
Bases: flexget.utils.search.StringComparator
Compares two strings for similarity based on extracted movie title, year and quality.
Compare the two strings, return True if they appear to be the same movie.
| Parameters: | other – String to compare against. If not specified, last specified string will be used. |
|---|---|
| Returns: | True if match is close enough. |
Return a cleaned string based on seq1 that can be used for searching.
Set first string for comparison.
Set second string for comparison.
Bases: difflib.SequenceMatcher, object
Compares two strings for similarity. Runs a cleaner function on strings before comparison. Cutoff similarity is configurable.
Compare the two strings, return True if match is close enough.
| Parameters: | other – String to compare against. If not specified, last specified string will be used. |
|---|---|
| Returns: | True if match is close enough. |
Return a cleaned string based on seq1 that can be used for searching.
Set first string for comparison.
Set second string for comparison.
Replaces common symbols with spaces. Also normalize unicode strings in decomposed form.
Removes common codec, sound keywords, and special characters info from titles to facilitate loose title comparison.
Returns a rating based on seeds and leeches for a given torrent.
| Parameters: |
|
|---|---|
| Returns: | A numeric rating |
NOTE:
Avoid using this module on your own or in plugins, this was originally made for 0.9 -> 1.0 transition.
You can safely use feed.simple_persistence and manager.persist, if we implement something better we can replace underlying mechanism in single point (and provide transparent switch).
Bases: flexget.utils.simple_persistence.SimplePersistence
Miscellaneous SQLAlchemy helpers.
Takes a list of table names and drops them from the database if they exist.
Find declaratively defined index from table by name
| Parameters: |
|
|---|---|
| Returns: | Index object |
Adds a column to a table
Warning
Uses raw statements, probably needs to be changed in order to work on other databases besides SQLite
| Parameters: |
|
|---|
| Parameters: |
|
|---|---|
| Returns: | List of column names in the table or empty list |
Use SQLAlchemy reflect to check table existences.
| Parameters: |
|
|---|---|
| Returns: | True if table exists, False otherwise |
| Return type: | bool |
| Returns: | Table schema using SQLAlchemy reflect as it currently exists in the db |
|---|---|
| Return type: | Table |
Bases: exceptions.Exception
Error raised when there is a problem with jinja rendering.
Formats a number according to the user’s locale.
Returns a string representation of a datetime object according to format string.
Pads a number or string with fillchar to the specified width.
Attempts to parse a date according to the rules in RFC 2822
Base name of a path.
Directory containing the given path.
Extension of a path (including the ‘.’).
Base name of a path, without its extension.
Replace problematic characters in a path.
Perform a regexp replacement on the given string.
Perform a search for given regexp pattern, return the matching portion of the text.
Create our environment and add our custom filters
Renders a Template or template string with an Entry as its context.
Renders a Template with an feed as its context.
Contains miscellaneous helpers
Bases: exceptions.Exception
Bases: list
A list that stores regexps.
You can add compiled or uncompiled regexps to the list. It will always return the compiled version. It will compile the text regexps on demand when first accessed.
Bases: urllib2.HTTPRedirectHandler
Print to console safely.
Returns given bytes as prettified string.
| Parameters: | value (string) – String to be html-decoded |
|---|---|
| Returns: | Html decoded string |
Encode unicode_data for use as XML or HTML, with characters outside of the encoding converted to XML numeric character references.
Removes invalid characters from windows pathnames
Merges dictionary d1 into dictionary d2. d1 will remain in original form.
Makes dictionary d contain only yaml.safe_dump compatible elements. On other words, remove all non standard types from dictionary.
Tries to strip all HTML tags from text. If unsuccessful returns original text.
Utility function for pulling back a url, with a retry of 3 times, increasing the timeout, etc. Re-raises any errors as URLError.
Warning
This is being replaced by requests library. flexget.utils.requests should be used going forward.
| Parameters: |
|
|---|---|
| Returns: | The file-like object returned by urlopen |