Skip to content

module.Api.Api

Jonas edited this page Jun 8, 2016 · 1 revision

class module.Api.Api(core)

pyLoads API

This is accessible either internal via core.api or via thrift backend.

see Thrift specification file remote/thriftbackend/pyload.thrift for information about data structures and what methods are usuable with rpc.

Most methods requires specific permissions, please look at the source code if you need to know. These can be configured via webinterface. Admin user have all permissions, and are the only ones who can access the methods with no specific permission.

__init__(core)

You can find the whole Sourcecode here: (source)

Name Discription
__init__(core)
addFiles(pid, links) Adds files to specific package.
addPackage(name, links[, dest]) Adds a package, with links to desired destination.
call(info) Calls a service (a method in hook plugin).
changePassword(user, oldpw, newpw) changes password for specific user
checkAndAddPackages(links[, dest]) Checks online status, retrieves names, and will add packages.
checkAuth(username, password[, remoteip]) Check authentication and returns details
checkOnlineStatus(urls) initiates online status check
checkOnlineStatusContainer(urls, container, data) checks online status of urls and a submited container file
checkURLs(urls) Gets urls and returns pluginname mapped to list of matches urls.
deleteFiles(fids) Deletes several file entries from pyload.
deleteFinished() Deletes all finished files and completly finished packages.
deletePackages(pids) Deletes packages and containing links.
freeSpace() Available free space at download directory in bytes
generateAndAddPackages(links[, dest]) Generates and add packages
generatePackages(links) Parses links, generates packages names from urls
getAccountTypes() All available account types.
getAccounts(refresh) Get information about all entered accounts.
getAllInfo() Returns all information stored by hook plugins.
getAllUserData() returns all known user and info
getCaptchaTask([exclusive]) Returns a captcha task
getCaptchaTaskStatus(tid) Get information about captcha task
getCollector() same as getQueue for collector.
getCollectorData() same as getQueueData for collector.
getConfig() Retrieves complete config of core.
getConfigDict() Retrieves complete config in dict format, not for RPC.
getConfigValue(category, option[, section]) Retrieve config value.
getEvents(uuid) Lists occured events, may be affected to changes in future.
getFileData(fid) Get complete information about a specific file.
getFileOrder(pid) Information about file order within package.
getInfoByPlugin(plugin) Returns information stored by a specific plugin.
getLog([offset]) Returns most recent log entries.
getPackageData(pid) Returns complete information about package, and included files.
getPackageInfo(pid) Returns information about package, without detailed information about containing files
getPackageOrder(destination) Returns information about package order.
getPluginConfig() Retrieves complete config for all plugins.
getPluginConfigDict() Plugin config as dict, not for RPC.
getQueue() Returns info about queue and packages, not about files, see getQueueData or getPackageData instead.
getQueueData() Return complete data about everything in queue, this is very expensive use it sparely.
getServerVersion() pyLoad Core version
getServices() A dict of available services, these can be defined by hook plugins.
getUserData(username, password) similar to checkAuth but returns UserData thrift type
hasService(plugin, func) Checks wether a service is available.
isAuthorized(func, userdata) checks if the user is authorized for specific method
isCaptchaWaiting() Indicates wether a captcha task is available
isTimeDownload() Checks if pyload will start new downloads according to time in config.
isTimeReconnect() Checks if pyload will try to make a reconnect
kill() Clean way to quit pyLoad
login(username, password[, remoteip]) Login into pyLoad, this must be called when using rpc before any methods can be used.
moveFiles(fids, pid) Move multiple files to another package
movePackage(destination, pid) Set a new package location.
orderFile(fid, position) Gives a new position to a file within its package.
orderPackage(pid, position) Gives a package a new position.
parseURLs([html, url]) Parses html content or any arbitaty text for links and returns result of checkURLs
pauseServer() Pause server: Tt wont start any new downloads, but nothing gets aborted.
pollResults(rid) Polls the result available for ResultID
pullFromQueue(pid) Moves package from Queue to Collector.
pushToQueue(pid) Moves package from Collector to Queue.
recheckPackage(pid) Proofes online status of all files in a package, also a default action when package is added.
removeAccount(plugin, account) Remove account from pyload.
restart() Restart pyload core
restartFailed() Restarts all failed failes.
restartFile(fid) Resets file status, so it will be downloaded again.
restartPackage(pid) Restarts a package, resets every containing files.
setCaptchaResult(tid, result) Set result for a captcha task
setConfigValue(category, option, value[, ...]) Set new config value.
setPackageData(pid, data) Allows to modify several package attributes.
setPackageName(pid, name) Renames a package.
setUserPermission(user, permission, role)
statusDownloads() Status off all currently running downloads.
statusServer() Some general information about the current status of pyLoad.
stopAllDownloads() Aborts all running downloads.
stopDownloads(fids) Aborts specific downloads.
togglePause() Toggle pause state.
toggleReconnect() Toggle reconnect activation.
unpauseServer() Unpause server: New Downloads will be started.
updateAccount(plugin, account[, password, ...]) Changes pw/options for specific account.
uploadContainer(filename, data) Uploads and adds a container file to pyLoad.

You can find the whole Sourcecode here: (source)


####getConfigValue(category, option, section='core')

Retrieve config value.

Parameters:

  • category – name of category, or plugin
  • option – config option
  • section – ‘plugin’ or ‘core’

Returns: config value as string


####setConfigValue(category, option, value, section='core')

Set new config value.

Parameters:

  • category
  • option
  • value – new config value
  • section – ‘plugin’ or ‘core

####getConfig()

Retrieves complete config of core.

Returns: list of ConfigSection


####getConfigDict()

Retrieves complete config in dict format, not for RPC.

Returns: dict


####getPluginConfig()

Retrieves complete config for all plugins.

Returns: list of ConfigSection


####getPluginConfigDict()

Plugin config as dict, not for RPC.

Returns: dict


####pauseServer()

Pause server: Tt wont start any new downloads, but nothing gets aborted.


####unpauseServer()

Unpause server: New Downloads will be started.


####togglePause()

Toggle pause state.

Returns: new pause state


####toggleReconnect()

Toggle reconnect activation.

Returns: new reconnect state


####statusServer()

Some general information about the current status of pyLoad.

Returns: ServerStatus


####freeSpace()

Available free space at download directory in bytes


####getServerVersion()

pyLoad Core version


####kill()

Clean way to quit pyLoad


####restart()

Restart pyload core


####getLog(offset=0)

Returns most recent log entries.

Parameters: offset – line offset Returns: List of log entries


####isTimeDownload()

Checks if pyload will start new downloads according to time in config.

Returns: bool


####isTimeReconnect()

Checks if pyload will try to make a reconnect

Returns: bool


####statusDownloads()

Status off all currently running downloads.

Returns: list of DownloadStatus


####addPackage(name, links, dest=1)

Adds a package, with links to desired destination.

Parameters:

  • name – name of the new package
  • links – list of urls
  • dest – Destination Returns:

package id of the new package


####parseURLs(html=None, url=None)

Parses html content or any arbitaty text for links and returns result of checkURLs

Parameters: html – html source Returns:


####checkURLs(urls)

Gets urls and returns pluginname mapped to list of matches urls.

Parameters: urlsReturns: {plugin: urls}


####checkOnlineStatus(urls)

initiates online status check

Parameters: urlsReturns: initial set of data as OnlineCheck instance containing the result id


####checkOnlineStatusContainer(urls, container, data)

checks online status of urls and a submited container file

Parameters:

  • urls – list of urls
  • container – container file name
  • data – file content Returns:

online check


####pollResults(rid)

Polls the result available for ResultID

Parameters: rid – ResultID Returns: OnlineCheck, if rid is -1 then no more data available


####generatePackages(links)

Parses links, generates packages names from urls

Parameters: links – list of urls Returns: package names mapped to urls


####generateAndAddPackages(links, dest=1)

Generates and add packages

Parameters:

  • links – list of urls
  • dest – Destination Returns:

list of package ids


####checkAndAddPackages(links, dest=1)

Checks online status, retrieves names, and will add packages. Because of this packages are not added immediatly, only for internal use.

Parameters:

  • links – list of urls
  • dest – Destination Returns:

None


####getPackageData(pid)

Returns complete information about package, and included files.

Parameters: pid – package id Returns: PackageData with .links attribute


####getPackageInfo(pid)

Returns information about package, without detailed information about containing files

Parameters: pid – package id Returns: PackageData with .fid attribute


####getFileData(fid)

Get complete information about a specific file.

Parameters: fid – file id Returns: FileData


####deleteFiles(fids)

Deletes several file entries from pyload.

Parameters: fids – list of file ids


####deletePackages(pids)

Deletes packages and containing links.

Parameters: pids – list of package ids


####getQueue()

Returns info about queue and packages, not about files, see getQueueData or getPackageData instead.

Returns: list of PackageInfo


####getQueueData()

Return complete data about everything in queue, this is very expensive use it sparely. See getQueue for alternative.

Returns: list of PackageData


####getCollector()

same as getQueue for collector.

Returns: list of PackageInfo


####getCollectorData()

same as getQueueData for collector.

Returns: list of PackageInfo


####addFiles(pid, links)

Adds files to specific package.

Parameters:

  • pid – package id
  • links – list of urls

####pushToQueue(pid)

Moves package from Collector to Queue.

Parameters: pid – package id


####pullFromQueue(pid)

Moves package from Queue to Collector.

Parameters: pid – package id


####restartPackage(pid)

Restarts a package, resets every containing files.

Parameters: pid – package id


####restartFile(fid)

Resets file status, so it will be downloaded again.

Parameters: fid – file id


####recheckPackage(pid)

Proofes online status of all files in a package, also a default action when package is added.

Parameters: pidReturns:


####stopAllDownloads()

Aborts all running downloads.


####stopDownloads(fids)

Aborts specific downloads.

Parameters: fids – list of file ids Returns:


####setPackageName(pid, name)

Renames a package.

Parameters:

  • pid – package id
  • name – new package name

####movePackage(destination, pid)

Set a new package location.

Parameters:

  • destination – Destination
  • pid – package id

####moveFiles(fids, pid)

Move multiple files to another package

Parameters:

  • fids – list of file ids
  • pid – destination package Returns:

####uploadContainer(filename, data)

Uploads and adds a container file to pyLoad.

Parameters:

  • filename – filename, extension is important so it can correctly decrypted
  • data – file content

####orderPackage(pid, position)

Gives a package a new position.

Parameters:

  • pid – package id
  • position

####orderFile(fid, position)

Gives a new position to a file within its package.

Parameters:

  • fid – file id
  • position

####setPackageData(pid, data)

Allows to modify several package attributes.

Parameters:

  • pid – package id
  • data – dict that maps attribute to desired value

####deleteFinished()

Deletes all finished files and completly finished packages.

Returns: list of deleted package ids


####restartFailed()

Restarts all failed failes.


####getPackageOrder(destination)

Returns information about package order.

Parameters: destination – Destination Returns: dict mapping order to package id


####getFileOrder(pid)

Information about file order within package.

Parameters: pidReturns: dict mapping order to file id


####isCaptchaWaiting()

Indicates wether a captcha task is available

Returns: bool


####getCaptchaTask(exclusive=False)

Returns a captcha task

Parameters: exclusive – unused Returns: CaptchaTask


####getCaptchaTaskStatus(tid)

Get information about captcha task

Parameters: tid – task id Returns: string


####setCaptchaResult(tid, result)

Set result for a captcha task

Parameters:

  • tid – task id
  • result – captcha result

####getEvents(uuid)

Lists occured events, may be affected to changes in future.

Parameters: uuidReturns: list of Events


####getAccounts(refresh)

Get information about all entered accounts.

Parameters: refresh – reload account info Returns: list of AccountInfo


####getAccountTypes()

All available account types.

Returns: list


####updateAccount(plugin, account, password=None, options={})

Changes pw/options for specific account.


####removeAccount(plugin, account)

Remove account from pyload.

Parameters:

  • plugin – pluginname
  • account – accountname

####login(username, password, remoteip=None)

Login into pyLoad, this must be called when using rpc before any methods can be used.

Parameters:

  • username
  • password
  • remoteip – Omit this argument, its only used internal Returns:

bool indicating login was successful


####checkAuth(username, password, remoteip=None)

Check authentication and returns details

Parameters:

  • username
  • password
  • remoteipReturns:

dict with info, empty when login is incorrect


####isAuthorized(func, userdata)

checks if the user is authorized for specific method

Parameters:

  • func – function name
  • userdata – dictionary of user data Returns:

boolean


####getUserData(username, password)

similar to checkAuth but returns UserData thrift type


####getAllUserData()

returns all known user and info


####getServices()

A dict of available services, these can be defined by hook plugins.

Returns: dict with this style: {“plugin”: {“method”: “description”}}


####hasService(plugin, func)

Checks wether a service is available.

Parameters:

  • plugin
  • funcReturns:

bool


####call(info)

Calls a service (a method in hook plugin).

Parameters: info – ServiceCall Returns: result | | Raises : | ServiceDoesNotExists, when its not available | | Raises : | ServiceException, when a exception was raised


####getAllInfo()

Returns all information stored by hook plugins. Values are always strings

Returns: {“plugin”: {“name”: value } }


####getInfoByPlugin(plugin)

Returns information stored by a specific plugin.

Parameters: plugin – pluginname Returns: dict of attr names mapped to value {“name”: value}


####changePassword(user, oldpw, newpw)

changes password for specific user

Clone this wiki locally