Esamlib

From EventScripts Community Encyclopedia


Module: esamlib

Module Overview

EventScripts version: 2.0.0.248d or later

Table of Contents

Contents


Description

Provides an interface for the ESAM SDK.

Quick Example

Retrieving ESAM addon information:
>>> import esamlib
 
>>> css = esamlib.getAddon('cssoundtrack')
 
>>> css.getElementNames()
['addon', 'id', 'author', 'authorid', 'name', 'basename', 'approved', 'es_load', 'date', 'woots', 'desc', 'summary', 'currentversion', 'versionnotes', 'video','defaultssid']
 
>>> css.download()
<StringIO.StringIO instance at 0x115BF738>
 
>>> css.currentversion
'7'
>>> css.approved
'1'
 
>>> css.get('approved')
'1'
Retrieving ESAM user information:
>>> import esamlib
 
>>> sd = esamlib.getUser('SuperDave')
 
>>> sd.getElementNames()
['username', 'userid', 'addontotal', 'addonrank', 'woottotal', 'wootrank', 'downloadtotal', 'downloadrank']
 
>>> sd.username
'SuperDave'
>>> sd.userid
'11091'
>>> sd.downloadrank
'4'
 
>> sd.get('userid')
'11091'
 
>>> sd.addons.getAddonNameList()
['cheapbombtimer', 'regenmod', 'cheapzombie', 'cheapdeathmatch', 'gunmod', 'cheapwirecut', 'swapwithvictim', 'slomomod', 'slobot', 'knifegrenade', 'newrewards', 'cssoundtrack', 'cheapbleed', 'explosivedeaths', 'nadeslay', 'healmates', 'teamfog', 'healthregen', 'weaponstats', 'splashdamage', 'doublevip', 'cheapbeacon','nowyouseeme', 'coloredhealth', 'bomberman', 'sourceradar', 'ezrestrict', 'assistedkills', 'randmaps', 'iedmod', 'safespawn', 'ezfilter', 'extendedevents', 'iptocountry', 'cheapbulletwhizz', 'cheapemote']
 
>>> sd.addons.cssoundtrack
<esamlib.Addon object at 0x1173AB70>
>>> sd.addons.find('cssoundtrack')
<esamlib.Addon object at 0x1173AB70>
 
>>> sd.addons.cssoundtrack.getElementNames()
['addon', 'id', 'author', 'authorid', 'name', 'basename', 'approved', 'es_load', 'date', 'woots', 'desc', 'summary', 'currentversion', 'versionnotes', 'video','defaultssid']
 
>>> sd.addons.cssoundtrack.id
'13758'
>>> sd.addons.cssoundtrack.currentversion
'7'
>>> sd.addons.cssoundtrack.video
'http://www.youtube.com/v/G3S8l3BB4J0'
>>> sd.addons.cssoundtrack.woots
'21'
>>> sd.addons.cssoundtrack.date
'2007-05-02 04:21:26'
>>> sd.addons.cssoundtrack.defaultssid
'200'
Upload functions:
# API keys can be obtained from: http://addons.eventscripts.com/manage/api_key/
 
# Upload to in-use basename gungame3
>>> esamlib.upload('SuperDave', my_api_key, 'gungame3', 'c:\\Redirect.zip', 'Redirect', '1.0', 'Version notes', 'Another SD test upload', 'Test summary', 'redirect', '2.0')
'Error: Basename in use by another user.'
 
# Upload to available basename sd_redirect
>>> esamlib.upload('SuperDave', my_api_key, 'sd_redirect', 'c:\\Redirect.zip', 'Redirect', '1.0', 'Version notes', 'Another SD test upload', 'Test summary', 'redirect', '2.0')
'Success! Addon ID# 16569'
 
# Add GODJonez as a collaborator on the redirect project
>>> esamlib.addCollaborator('SuperDave', my_api_key, 'sd_redirect', 'GODJonez')
'GODJonez added successfully to sd_redirect'
 
# Remove GODJonez as a collaborator on the redirect project
>>> esamlib.removeCollaborator('SuperDave', my_api_key, 'sd_redirect', 'GODJonez')
'GODJonez removed successfully from sd_redirect'
Query functions:
# Unless otherwise specified, query functions return a list (in order, if meaningful) of dictionaries of addon/user information.
 
# Query the leader and collaborators of an addon with the return format (leader, [collaborators,])
>>> esamlib.getCollaborators('sentrysounds')
('Mattie', ['HellenAngel'])
 
# Query [NATO]Hunter's addons
>>> result = esamlib.search(esamlib.SEARCH_USER, 'Hunter')
 
# Query all addons that require at least ES 2.1
>>> result = esamlib.search(esamlib.SEARCH_ESVERSION, '2.1')
 
# Query the top four addons by woots
>>> result = esamlib.topAddons(esamlib.TOP_WOOTS, 4)
 
# Query the top three users by number of addons
>>> result = esamlib.topUsers(esamlib.TOP_ADDONCOUNT, 3)
 
# Query the top ten users by downloads
>>> result = esamlib.topUsers(esamlib.TOP_DOWNLOADS)
 
# Query the addons updated less than one day ago
>>> result = esamlib.updated_since(time.time() - 86400)
 
# Query addons watched by XE_ManUp
>>> result = esamlib.watchedBy('XE_ManUp')

Module Content

Classes

Methods

esamlib.addCollaborator(username, api_key, basename, collaborator)
Adds a collaborator an existing addon where collaborator is the username of the collaborator to add. See obtaining an API key.
esamlib.getAddon(basename, log=esamlib.dbglog)
Returns an esamlib.ESAMAddon instance that provides access to addon information from the ESAM.
esamlib.getUser(username, log=esamlib.dbglog)
Returns an esamlib.ESAMUser instance that provides access to ESAM user information.
esamlib.removeCollaborator(username, api_key, basename, collaborator)
Removes a collaborator an existing addon where collaborator is the username of the collaborator to remove. See obtaining an API key.
esamlib.search(searchtype, text)
Returns a list of dictionaries containing the addon information of search results. See esamlib constants for valid searchtype values.
esamlib.topAddons(sortby, count=10)
Returns a list of dictionaries containing addon information for the top users sorted according to the value of sortby. See esamlib constants for valid sortby values.
esamlib.topUsers(sortby, count=10)
Returns a list of dictionaries containing user information for the top users sorted according to the value of sortby. See esamlib constants for valid sortby values.
esamlib.updated_since(timestamp)
Returns a list of dictionaries containing the addon information of addons updated since the Unix time specified.
esamlib.upload(username, api_key, basename, path, addon_name, version, version_notes, addon_desc, addon_summary, es_load_args, es_version, forum_url='', public_variable='', video_url='', install_instructions='', featurelist_url='', ready4approval=False, status='Normal')
Uploads an addon to the ESAM and returns the result in plain text. See obtaining an API key.

Constants

esamlib.SEARCH_ADDON
For use with the searchtype parameter with esamlib.search, searches for addons using multiple fields (name, desc, etc).
esamlib.SEARCH_DESCRIPTION
For use with the searchtype parameter with esamlib.search, searches for addons by description.
esamlib.SEARCH_ESVERSION
For use with the searchtype parameter with esamlib.search, searched for addons by minimum ES version.
esamlib.SEARCH_NAME
For use with the searchtype parameter with esamlib.search, searches for addons by name.
esamlib.SEARCH_PUBLICVAR
For use with the searchtype parameter with esamlib.search, searches for addons by public variable (see es.makepublic).
esamlib.SEARCH_USER
For use with the searchtype parameter with esamlib.search, searches for addons by author.
esamlib.TOP_ADDONCOUNT
For use with the sortby parameter with esamlib.topUsers only, returns the users with most number of addons.
esamlib.TOP_DOWNLOADS
For use with the sortby parameter with esamlib.topAddons or esamlib.topUsers, returns the users or addons with the most downloads.
esamlib.TOP_WOOTS
For use with the sortby parameter with esamlib.topAddons or esamlib.topUsers, returns the users or addons with the most number of +woots.

See Also

Notes

blog comments powered by Disqus