Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Slideshare API endpoint URLs #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions pyslideshare2/pyslideshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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.'
Expand Down Expand Up @@ -455,4 +469,3 @@ def main():
if __name__ == "__main__":
main()