flexget.utils.cache module#

flexget.utils.cache.cached_resource(url, base_dir, force=False, max_size=250, directory='cached_resources')[source]#

Cache a remote resource to local filesystem.

Return a tuple of local file name and mime type, use primarily for API/WebUI.

Parameters:
  • url (str) – Resource URL

  • force (bool) – Does not check for existence of cached resource, fetches the remote URL, ignores directory size limit

  • max_size (int) – Maximum allowed size of directory, in MB.

  • directory (str) – Name of directory to use. Default is cached_resources

  • base_dir (Path)

Returns:

Tuple of file path and mime type

Return type:

tuple[Path, str]

flexget.utils.cache.dir_size(directory)[source]#

Sum the size of all files in a given dir. Not recursive.

Parameters:

directory (Path) – Directory to check

Returns:

Summed size of all files in Bytes.

Return type:

int

flexget.utils.cache.trim_dir(directory)[source]#

Remove the least accessed file on a given dir.

Parameters:

directory (Path) – Directory to check

Return type:

None