Welcome to pyliveleak’s documentation!¶
Contents:
pyliveleak¶
Uploads videos to liveleak.com
- Free software: MIT license
- Documentation: https://pyliveleak.readthedocs.io.
Features¶
Sample usage:
$ pyliveleak --path tests/test-data/foreman_cif.mp4 --username "$username" --password "$password"
https://www.liveleak.com/view?i=7ed_1502358506
For additional options:
$ pyliveleak --help
Usage: pyliveleak [OPTIONS]
Console script for pyliveleak.
Options:
--loglevel INTEGER
--password TEXT Your liveleak.com password [required]
--username TEXT Your liveleak.com username [required]
--path PATH The video to upload [required]
--help Show this message and exit.
You may also use pyliveleak as a Python library:
>>> 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']
Credits¶
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Installation¶
Stable release¶
To install pyliveleak, run this command in your terminal:
$ pip install pyliveleak
This is the preferred method to install pyliveleak, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
From sources¶
The sources for pyliveleak can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/mpenkov/pyliveleak
Or download the tarball:
$ curl -OL https://github.com/mpenkov/pyliveleak/tarball/master
Once you have a copy of the source, you can install it with:
$ python setup.py install
pyliveleak¶
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:
- Upload the video file to liveleak’s AWS S3 bucket.
- Add the file to liveleak, yielding a file token.
- Specify metadata and publish the video.
-
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.
-
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.
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:
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:
-
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}
-
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/mpenkov/pyliveleak/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation¶
pyliveleak could always use more documentation, whether as part of the official pyliveleak docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/mpenkov/pyliveleak/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up pyliveleak for local development.
Fork the pyliveleak repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/pyliveleak.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv pyliveleak $ cd pyliveleak/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 pyliveleak tests $ python setup.py test or py.test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check https://travis-ci.org/mpenkov/pyliveleak/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- Michael Penkov <misha.penkov@gmail.com>
Contributors¶
None yet. Why not be the first?
History¶
0.1.2 (2017-08-11)¶
Fixed¶
- Include categories.yml (and VERSION) in package data, for real this time.
0.1.1 (2017-08-10)¶
Added¶
- More Sphinx documentation
Fixed¶
- Include categories.yml in package data.
- Update Sphinx version so that documentation builds properly.
0.1.0 (2017-08-10)¶
- First release on PyPI.