Players

Remember instance an object of FouryouseeAPI, according to the basic set up

Getting the players

fouryousee.FouryouseeAPI.get_players(self, **kwargs)

Get the players of the 4YouSee account.

Parameters

id (int, optional) – Id of the player

Returns

List of dicts, where every dict, depicts a player.

Return type

list

Usage

Once “my” object has been created. You can execute the next:

Getting all players. It will return all the players of your account. It will be a list of dicts. If there is no player will return a empty list.

>>> my.get_players()
[
   {
      "id":1,
      "name":"Player DEMO",
      "description":"Ponto de demonstração disponibilizado na
                    instalação do 4YouSee Manager.Player demo available
                    on  4YouSee Manager installation.",
      "platform":"ANDROID",
      "lastContactInMinutes":224998,
      "group":{ "id":1, "name":"Group DEMO" },
      "playerStatus":{
         "id":5,
         "name":"Local assist needed",
         "time":9999999
      },
      "playlists":{
         "0":{ "id":3, "name":"Novo" },
         "1":{ "id":3, "name":"Novo" },
         "2":{ "id":3, "name":"Novo" },
         "3":{ "id":3, "name":"Novo" },
         "4":{ "id":3, "name":"Novo" },
         "5":{ "id":3, "name":"Novo" },
         "6":{ "id":3, "name":"Novo" }
      },
      "audios":{
         "0":{ "id":1, "name":"Contenido Vertical" }
      },
      "lastLogReceived":"2022-01-26 13:49:28"
   },
   {
      "id":2,
      "name":"Sample name via API",
      "description":"Description from API",
      "platform":"SAMSUNG",
      "lastContactInMinutes":1,
      "group":{ "id":2, "name":"Clientes Barrio Sur" },
      "playerStatus":{
         "id":1,
         "name":"Online",
         "time":10
      },
      "playlists":{
         "0":{ "id":1, "name":"Contenido Vertical" },
         "1":{ "id":1, "name":"Contenido Vertical" },
         "2":{ "id":1, "name":"Contenido Vertical" },
         "3":{ "id":1, "name":"Contenido Vertical" },
         "4":{ "id":1, "name":"Contenido Vertical" },
         "5":{ "id":1, "name":"Contenido Vertical" },
         "6":{ "id":1, "name":"Contenido Vertical" }
      },
      "audios":{
         "0":{ "id":1, "name":"Contenido Vertical" }
      },
      "lastLogReceived":"2022-07-01 16:46:33"
   }
]

If you know the player id

>>> my.get_players(id=1)
{
   "id":1,
   "name":"Player DEMO",
   "description":"Ponto de demonstração disponibilizado na
                instalação do 4YouSee Manager.Player demo available on
                4YouSee Manager installation.",
   "platform":"ANDROID",
   "lastContactInMinutes":224999,
   "group":{ "id":1, "name":"Group DEMO" },
   "playerStatus":{
      "id":5,
      "name":"Local assist needed",
      "time":9999999
   },
   "playlists":{
      "0":{ "id":3, "name":"Novo" },
      "1":{ "id":3, "name":"Novo" },
      "2":{ "id":3, "name":"Novo" },
      "3":{ "id":3, "name":"Novo" },
      "4":{ "id":3, "name":"Novo" },
      "5":{ "id":3, "name":"Novo" },
      "6":{ "id":3, "name":"Novo" }
   },
   "audios":{
      "0":{ "id":1, "name":"Contenido Vertical" }
   },
   "lastLogReceived":"2022-01-26 13:49:28"
}

If the id doesn’t exists.

>>> my.get_players(id=123_456)
Exception: {"message":"Player with ID 123456 was not found"}

Advanced Usage

  • Getting the playlists id’s of the players. If two players

    share the same playlist, it will consider just one.

>>> my.get_players()  # Updating the player attribute
>>> active_playlists = set()
>>> for player in my.players:
...    active_playlists.add(player['playlists']['0']['id'])
>>> active_playlists
{1, 67, 3, 4, 5, 8}

Adding the players

fouryousee.FouryouseeAPI.add_player(self, **kwargs) dict

Create a new player in the 4yousee account.

Parameters
  • name (str, required) – Display name.

  • description (str, optional) – Detailed player description.

  • platform (str, required) – Platform where the 4yousee player will be executed. They can be 4YOUSEE_PLAYER or SAMSUNG or ANDROID or LG

  • group (int, optional) – Id of a group of players.

  • playlists (dict, required) – Dict with 7 keys and 7 values. Every key depicts the number of the day (starting from 0) and every value the playlist id.

  • audios (dict, optional) – A dict with “0” as his only key and a value that depicts the id of the audio playlist

Returns

Dict that depicts the player created.

Return type

dict

Usage

Passing only the required params

>>> my.add_player(name='Player Example',
...               platform='ANDROID',
...               playlists={ "0": 1, "1": 1, "2": 1, "3": 1, "4": 1, "5": 1, "6": 1 })
{
  "id": 6,
  "name": "Player name example",
  "description": "Player description example",
  "platform": "ANDROID",
  "lastContactInMinutes": null,
  "group": { "id": 1, "name": "Group DEMO" },
  "playerStatus": { "id": 6, "name": "Never accessed", "time": 0 },
  "playlists": {
    "0": { "id": 1, "name": "Playlist DEMO" },
    "1": { "id": 1, "name": "Playlist DEMO" },
    "2": { "id": 1, "name": "Playlist DEMO" },
    "3": { "id": 1, "name": "Playlist DEMO" },
    "4": { "id": 1, "name": "Playlist DEMO" },
    "5": { "id": 1, "name": "Playlist DEMO" },
    "6": { "id": 1, "name": "Playlist DEMO" }
  },
  "audios": { "0": None }
  "lastLogReceived": None
}

Passing all the params

>>> >>> my.add_player(name='Player Example',
...                   description='Extra information for this player',
...                   platform='4YOUSEE_PLAYER',
...                   playlists={ "0": 24 "1": 24 "2": 24 "3": 24 "4": 24 "5": 24 "6": 24 },
...                   group=2,
...                   audios={'0': 8}
{
   "id":25,
   "name":"Player Example",
   "description":"Extra information for this player",
   "platform":"4YOUSEE_PLAYER",
   "lastContactInMinutes":"None",
   "group":{ "id":2, "name":"Clientes Barrio Sur" },
   "playerStatus":{
      "id":6,
      "name":"Never accessed",
      "time":0
   },
   "playlists":{
      "0":{ "id":24, "name":"Player DEMO" },
      "1":{ "id":24, "name":"Player DEMO" },
      "2":{ "id":24, "name":"Player DEMO" },
      "3":{ "id":24, "name":"Player DEMO" },
      "4":{ "id":24, "name":"Player DEMO" },
      "5":{ "id":24, "name":"Player DEMO" },
      "6":{ "id":24, "name":"Player DEMO" }
   },
   "audios":{
      "0":{ "id":8, "name":"Prueba 1" }
   },
   "lastLogReceived":"None"
}

Editing players

fouryousee.FouryouseeAPI.edit_player(self, **kwargs)
Update a Player by id. When a param is not sent,
it will recognize the current values of the player

in the 4yousee account.

Parameters
  • id (int, required) – Id o the player.

  • name (str, optional) – Player display name.

  • description (str, optional) – Detailed player description.

  • platform (str, required) – Platform where the 4yousee player will be executed. Ex. 4YOUSEE_PLAYER or SAMSUNG or ANDROID ou LG

  • group (int, optional) – Id of a group of players.

  • playlists (dict, optional) – Dict with 7 keys and 7 values. Every key depicts the number of the day (starting from 0) and every value the playlist id.

  • audios (dict, optional) – A dict with “0” as his only key and a value that depicts the id of the audio playlist.

Returns

Dict that depicts the player edited

Return type

dict

Usage

Once “my” object has been created. You can execute the next:

Changing the name, platform and playlist

>>> my.edit_player(id=2, name='New player name',
...                platform='SAMSUNG',
...                playlists={ "0": 40, "1": 40, "2": 40, "3": 40, "4": 40, "5": 40, "6": 40 })
{
  "id": 2,
  "name": "New player name",
  "description": "Description from API",
  "platform": "SAMSUNG",
  "lastContactInMinutes": 998,
  "group": { "id": 2, "name": "Clientes Barrio Sur" },
  "playerStatus": {
    "id": 4,
    "name": "Assistance needed",
    "time": 1440
  },
  "playlists": {
    "0": { "id": 40, "name": "Player name example" },
    "1": { "id": 40, "name": "Player name example" },
    "2": { "id": 40, "name": "Player name example" },
    "3": { "id": 40, "name": "Player name example" },
    "4": { "id": 40, "name": "Player name example" },
    "5": { "id": 40, "name": "Player name example" },
    "6": { "id": 40, "name": "Player name example" }
  },
  "audios": {
    "0": { "id": 1, "name": "Contenido Vertical" }
  },
  "lastLogReceived": "2022-07-01 18:00:37"
}

Warning

It’ll raise this exception Exception: {“message”:”Can not update an inactive player”} if the license hasn’t been actived.

Deleting players

fouryousee.FouryouseeAPI.delete_player(self, spec_id: int)

Delete one player of the 4YouSee account.

Parameters

spec_id (int, required) – Id of a single player.

Returns

True in case the player was deleted successfully or False in case the player was not deleted.

Return type

bool

Usage

Once “my” object has been created. You can execute the next:

>>> my.delete_player(15)
True
>>> my.delete_player(123_456) # If doesn't exists
False

Advanced Usage

>>> my.get_medias(categoryId=10)