diff --git a/pyslideshare2/pyslideshare.py b/pyslideshare2/pyslideshare.py index 82f54a2..f0c2de3 100644 --- a/pyslideshare2/pyslideshare.py +++ b/pyslideshare2/pyslideshare.py @@ -33,12 +33,13 @@ API_VERSION = 2 service_url_dict = { - 'slideshow_by_user' : 'https://www.slideshare.net/api/%d/get_slideshow_by_user' % API_VERSION, + 'slideshow_by_user' : 'https://www.slideshare.net/api/%d/get_slideshows_by_user' % API_VERSION, 'get_slideshow' : 'https://www.slideshare.net/api/%d/get_slideshow' % API_VERSION, - 'slideshow_by_tag' : 'https://www.slideshare.net/api/%d/get_slideshow_by_tag' % API_VERSION, - 'slideshow_by_group' : 'https://www.slideshare.net/api/%d/get_slideshow_from_group' % API_VERSION, + 'slideshow_by_tag' : 'https://www.slideshare.net/api/%d/get_slideshows_by_tag' % API_VERSION, + 'slideshow_by_group' : 'https://www.slideshare.net/api/%d/get_slideshows_by_group' % API_VERSION, 'upload_slideshow' : 'https://www.slideshare.net/api/%d/upload_slideshow' % API_VERSION, - 'delete_slideshow' : 'https://www.slideshare.net/api/%d/delete_slideshow' % API_VERSION + 'delete_slideshow' : 'https://www.slideshare.net/api/%d/delete_slideshow' % API_VERSION, + 'slideshow_search' : 'https://www.slideshare.net/api/%d/search_slideshows' % API_VERSION } class Callable: @@ -315,15 +316,28 @@ def get_slideshow_by_user(self, username_for=None,offset=None,limit=None): username_for = self.params['username'] return self.make_call('slideshow_by_user', username_for=username_for, offset=offset, limit=limit) - def get_slideshow(self, slideshow_id=None, **args): + def get_slideshow(self, slideshow_id=None, slideshow_url=None, **args): """ Method to retrieve a slideshow, given an id - Requires: slideshow_id + Requires: slideshow_id or slideshow_url """ - if not slideshow_id: - print >> sys.stderr, 'slideshow_id is needed for this call.' + if not slideshow_id and not slideshow_url: + print >> sys.stderr, 'slideshow_id or slideshow_url is needed for this call.' sys.exit(1) - return self.make_call('get_slideshow', slideshow_id=str(slideshow_id), **args) + if slideshow_id: + return self.make_call('get_slideshow', slideshow_id=str(slideshow_id), **args) + elif slideshow_url: + return self.make_call('get_slideshow', slideshow_url=str(slideshow_url), **args) + + def get_slideshow_by_search(self, search_term=None, offset=None, limit=None): + """ + Requires: search_term + Optional: offset, limit + """ + if not search_term: + print >> sys.stderr, 'A search term is required for this call.' + sys.exit(1) + return self.make_call('slideshow_search', q=search_term, page=offset, order="latest", items_per_page=limit) def get_slideshow_by_tag(self, tag=None, offset=None, limit=None): """ @@ -356,7 +370,7 @@ def upload_slideshow(self, username=None, password=None, the value returned will be an id. Use get_slideshow to get the exact status Requires: username, password, slideshow_title, slideshow_srcfile Optional: slideshow_description, slideshow_tags, make_src_public, -make_slideshow_private, generate_secret_url, allow_embeds, share_with_contacts + make_slideshow_private, generate_secret_url, allow_embeds, share_with_contacts """ if not username or not password or not slideshow_title or not (slideshow_srcfile or upload_url): print >> sys.stderr, 'Required parameters missing.' @@ -455,4 +469,3 @@ def main(): if __name__ == "__main__": main() -