pyliveleak package

Submodules

pyliveleak.cli module

Console script for pyliveleak.

pyliveleak.pyliveleak module

Main module.

class pyliveleak.pyliveleak.AddItemPage(html, cookies)[source]

Bases: object

This internal class performs the hard work for adding a video to liveleak.com.

That is a three-stage process:
  1. Upload the video file to liveleak’s AWS S3 bucket.
  2. Add the file to liveleak, yielding a file token.
  3. Specify metadata and publish the video.
__init__(html, cookies)[source]
add_file(path, aws_response)[source]
connect_string

Parse the connect_string from the page.

This is unique for each page load.

connection

Parse the connection number from the page.

This is unique for each page load.

multipart_params

Parse the multipart_params dict from the JavaScript in the page.

We need these params to upload the file to AWS.

publish(title='title', body='body', tags='liveleak.py', category='other')[source]
upload_to_aws(path)[source]

Upload a file to AWS. Raises Exception on failure. :return: a file_token in case of success :rtype: str

class pyliveleak.pyliveleak.IndexPage(html, cookies)[source]

Bases: object

Represents a logged-in session with liveleak.com.

To obtain an instance of this class, see the pyliveleak.login() function.

__init__(html, cookies)[source]

Internal constructor.

Parameters:
  • html (str) – The HTML from the index page.
  • cookies (str) – A dictionary of cookies containing the entire session.
add_item(path, title=None, body=None, tags='liveleak.py', category='other')[source]

Upload a video to liveleak.com.

Parameters:
  • path (str) – The full path to the video to upload.
  • title (str) – The title of the video. If None, will be the filename of the video.
  • description (str) – A description of the video. If None, will be the filename of the video.
  • tags (str) – Tags for the video.
  • category (str) – The name of the category for the video.
Returns:

The file_token and item_token as a tuple.

You may use the item_token to access the uploaded video through your browser::
https://www.liveleak.com/view?i={item_token}
exception pyliveleak.pyliveleak.PyLiveleakException[source]

Bases: exceptions.RuntimeError

Raised when something unexpected happens within pyliveleak.

pyliveleak.pyliveleak.load_categories()[source]
pyliveleak.pyliveleak.login(username, password)[source]

Login to liveleak.com.

This is the main entry point to pyliveleak. Once you login, you can upload videos.

Parameters:
  • username (str) – Your liveleak.com username
  • password (str) – Your liveleak.com password
Returns:

A new session with liveleak.com.

Return type:

pyliveleak.IndexPage

Module contents

Sample usage:

>>> import pyliveleak
>>> index_page = pyliveleak.login(username, password)
>>> file_token, item_token = index_page.add_item('tests/test-data/foreman_cif.mp4')
>>> item_token
u'b86_1502357642'

Your new video will be available here: https://www.liveleak.com/view?i={item_token}

You may specify optional metadata:

>>> index_page.add_item('tests/test-data/foreman_cif.mp4', title='my title',
...                     body='detailed description', tags='tags', category='World News')

The category must be one of:

>>> pprint.pprint(sorted(pyliveleak.CATEGORIES))
['afghanistan',
 'citizen journalism',
 'conspiracy',
 'creative',
 'history',
 'hobbies',
 'iran',
 'iraq',
 'liveleak challenges',
 'liveleaks',
 'music',
 'nature',
 'other',
 'other entertainment',
 'other items from liveleakers',
 'other middle east',
 'other news',
 'politics',
 'propaganda',
 'regional news',
 'religion',
 'science and technology',
 'sports',
 'syria',
 'ukraine',
 'vehicles',
 'weapons',
 'world news',
 'wtf',
 'yawn',
 'your say']
pyliveleak.login(username, password)[source]

Login to liveleak.com.

This is the main entry point to pyliveleak. Once you login, you can upload videos.

Parameters:
  • username (str) – Your liveleak.com username
  • password (str) – Your liveleak.com password
Returns:

A new session with liveleak.com.

Return type:

pyliveleak.IndexPage

class pyliveleak.IndexPage(html, cookies)[source]

Bases: object

Represents a logged-in session with liveleak.com.

To obtain an instance of this class, see the pyliveleak.login() function.

__init__(html, cookies)[source]

Internal constructor.

Parameters:
  • html (str) – The HTML from the index page.
  • cookies (str) – A dictionary of cookies containing the entire session.
add_item(path, title=None, body=None, tags='liveleak.py', category='other')[source]

Upload a video to liveleak.com.

Parameters:
  • path (str) – The full path to the video to upload.
  • title (str) – The title of the video. If None, will be the filename of the video.
  • description (str) – A description of the video. If None, will be the filename of the video.
  • tags (str) – Tags for the video.
  • category (str) – The name of the category for the video.
Returns:

The file_token and item_token as a tuple.

You may use the item_token to access the uploaded video through your browser::
https://www.liveleak.com/view?i={item_token}