Metadata-Version: 2.1
Name: pyps4-2ndscreen
Version: 1.0.1
Summary: PS4 2nd Screen Python Library
Home-page: https://github.com/ktnrg45/pyps4-2ndscreen
Author: ktnrg45
Author-email: ktnrg45@gmail.com
License: LGPLv2+
Keywords: playstation sony ps4
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.5.3
Description-Content-Type: text/markdown
Requires-Dist: aiohttp (>=3.5.4)
Requires-Dist: click (>=7.0)
Requires-Dist: construct (>=2.9.45)
Requires-Dist: pycryptodomex (>=3.7.2)

Python Control for PlayStation 4 consoles.
==========================================

|BuildStatus| |PypiVersion| |PyPiPythonVersions|

Description
--------------------
A full Python implementation based on the Node.js package, ps4-waker.
This is an unofficial API for the PS4 2nd Screen App.

** This module is in beta development and will be re-released under a new name in PYPI at Version 1.0.0. Breaking changes and major code revisions will likely be made until then, to establish and revise the bulk of the framework for this module.

Compatibility
--------------------
Tested on:
Python 3.5/3.6/3.7

Installation
--------------------
It is advised to install the module in a virtual env:

.. code:: bash

    python -m venv .

    source bin/activate

To install run:

.. code:: bash

    pip install pyps4-2ndscreen

Protocol
--------------------
UDP is used to get status updates and retrieve user credentials. TCP is used to send commands to the PS4 Console.

Ports
--------------------
PS4 listens on ports 987 (Priveleged) to fetch user PSN credentials.
Must run command on python path if no access.

Example:

.. code:: bash

    sudo setcap 'cap_net_bind_service=+ep' /usr/bin/python3.5

This is so you do not need sudo/root priveleges to run.

Usage
=====================
API should be accessed initially like the following examples.

Most functions can be accessed from the high-level PS4 object. You will need to pass in th IP address of your PS4 and your PSN credentials.

There are several async/asyncio coroutine functions in this module. These functions should be accessed with an Asyncio loop.

There are two versions of the Ps4 object/class: Ps4() and Ps4Async(). The Ps4Async version is recommended over the legacy Ps4 version which may be deprecated in the future.
The difference between the two is that the Ps4() class uses synchronous sockets (socket.socket) while the Ps4Async() class uses asyncio transports and protocols. If using the Async version, a running asyncio event loop is required.

Getting Credentials
=====================

Your PSN Credentials can be generated by running a CLI command or by using the Python interpreter:

Terminal Command:

.. code:: bash

    pyps4-2ndscreen credentials

If your system does not have setcap utilities your may run the following command:

.. code:: bash

    sudo ./bin/pyps4-2ndscreen credentials

or

Python:

.. code:: python

    from pyps4_2ndscreen.credential import Credentials
    creds = Credentials()

    YourCredentials = creds.start()

This will start the credential service and will return the credentials for the PSN Account. You will need to get the PS4 Second Screen app for Android or iOS to do this. Once you have logged in with your acccount in the app and started the service, refresh the devices in the app and select the device named 'pyps4-2ndscreen'. 

Cover Art Issues
--------------------
If you find that media art cannot be found. Please post an issue with your Region, Country, Title of game, an ID of game.

To Do List:
--------------------
- Make PS button command more consistent.
- Docs


Credits:
--------------------
Thanks to hthiery for writing the underlying socket protocol in Python. https://github.com/hthiery/python-ps4

References:
--------------------

- https://github.com/dsokoloski/ps4-wake
- https://github.com/dhleong/ps4-waker
- https://github.com/hthiery/python-ps4

.. _ps4-waker: https://github.com/dhleong/ps4-waker

.. |BuildStatus| image:: https://travis-ci.org/ktnrg45/pyps4-2ndscreen.png?branch=master
                 :target: https://travis-ci.org/ktnrg45/pyps4-2ndscreen
.. |PyPiVersion| image:: https://badge.fury.io/py/pyps4-2ndscreen.svg
                 :target: http://badge.fury.io/py/pyps4-2ndscreen
.. |PyPiPythonVersions| image:: https://img.shields.io/pypi/pyversions/pyps4-2ndscreen.svg
                        :alt: Python versions
                        :target: http://badge.fury.io/py/pyps4-2ndscreen


