{"id":15896162,"url":"https://github.com/numberoverzero/brainfm","last_synced_at":"2025-03-20T15:32:28.407Z","repository":{"id":57416274,"uuid":"73163059","full_name":"numberoverzero/brainfm","owner":"numberoverzero","description":"UNOFFICIAL python client for brain.fm","archived":false,"fork":false,"pushed_at":"2020-07-14T13:28:14.000Z","size":37,"stargazers_count":52,"open_issues_count":3,"forks_count":5,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-07T09:06:31.285Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/numberoverzero.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-08T08:01:53.000Z","updated_at":"2024-09-23T13:10:18.000Z","dependencies_parsed_at":"2022-09-05T04:42:21.953Z","dependency_job_id":null,"html_url":"https://github.com/numberoverzero/brainfm","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberoverzero%2Fbrainfm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberoverzero%2Fbrainfm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberoverzero%2Fbrainfm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberoverzero%2Fbrainfm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/numberoverzero","download_url":"https://codeload.github.com/numberoverzero/brainfm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221776117,"owners_count":16878490,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-06T09:06:35.564Z","updated_at":"2024-10-28T04:02:20.245Z","avatar_url":"https://github.com/numberoverzero.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Unofficial Brain.fm Python Client (3.5+)\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThe ``Connection`` class exposes four operations: ``login``,\n``list_stations``, ``get_token`` and ``make_stream_url``.  Please open an\nissue if there's another operation you need.\n\nThis client requires Python 3.5+.\n\n================\n CLI Quickstart\n================\n\n::\n\n    $ pip install brainfm\n    $ brain init\n    Email: user@gdomain.com\n    Password: \u003chidden\u003e\n    Repeat for confirmation: \u003chidden\u003e\n\n    Add the following to your .profile, .bashrc, or equivalent:\n\n        export BRAINFM_SID=\"s%3...s0xo\"\n        export BRAINFM_STREAM_ENDPOINT=\"https://...\"\n\n    $ # ... commands to modify and reload profile ...\n    $ brain play 300\n\n====================\n Library Quickstart\n====================\n\n::\n\n    pip install brainfm\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e import brainfm\n    \u003e\u003e\u003e client = brainfm.Connection()\n    \u003e\u003e\u003e client.login(\"your@email.here\", \"hunter2\")\n    \u003e\u003e\u003e client.list_stations()\n    [{'name': 'Cinematic Music Focus', 'id': 300,\n      'string_id': 'explore.focus.cinematic'},\n     {'name': 'Beach Focus', 'id': 53,\n      'string_id': 'explore.focus.beach'},\n     ...]\n    \u003e\u003e\u003e token = client.get_token(53)\n    \u003e\u003e\u003e token\n    '63f4b59b-93f4-45e6-b0c2-eb6b1582fb96'\n    \u003e\u003e\u003e client.make_stream_url(token)\n    'https://stream.brain.fm/?tkn=63f4b59b-93f4-45e6-b0c2-eb6b1582fb96'\n\nNow, open the stream using that token::\n\n    https://stream.brain.fm/?tkn=63f4b59b-93f4-45e6-b0c2-eb6b1582fb96\n\n=====\n CLI\n=====\n\nYou must pass an sid with ``--sid`` or define an environment variable\n``BRAINFM_SID``.  You can use ``brain init`` to generate one:\n\n::\n\n    $ brain init\n    Email: user@gdomain.com\n    Password: \u003chidden\u003e\n    Repeat for confirmation: \u003chidden\u003e\n\n    Add the following to your .profile, .bashrc, or equivalent:\n\n        export BRAINFM_SID=\"s%3...s0xo\"\n        export BRAINFM_STREAM_ENDPOINT=\"https://...\"\n\nWhile setting ``BRAINFM_STREAM_ENDPOINT`` is not strictly necessary, the\ncli is faster when either the env var is defined or you provide the endpoint\nexplicitly: ``brain --stream-endpoint=... ls``\n\nUsage::\n\n    $ brain ls\n    +Playable Stations-------------+-----------------------+-------- +\n    | id  | name                   | string_id             | length  |\n    +-----+------------------------+-----------------------+-------- +\n    | 32  | Quick Relax            | relax.justrelax15min  | 15 mins |\n    | 34  | Relaxed Focus          | explore.relaxed       | 30 mins |\n    | 35  | Focus                  | focus.3               | 30 mins |\n    | 36  | Sleep                  | sleep                 | 45 mins |\n    | ... | ...                    | ...                   | ...     |\n    | 540 | Study Focus            | explore.focus.study   | 30 mins |\n    | 541 | LoFi Focus             | explore.focus.lowfi   | 30 mins |\n    +-----+------------------------+-----------------------+-------- +\n\n    $ brain ls -a\n    +All Stations------------------+-----------------------+-------- +\n    | id  | name                   | string_id             | length  |\n    +-----+------------------------+-----------------------+-------- +\n    | 0   | Favorites              | None                  | None    |\n    | 32  | Quick Relax            | relax.justrelax15min  | 15 mins |\n    | 34  | Relaxed Focus          | explore.relaxed       | 30 mins |\n    | ... | ...                    | ...                   | ...     |\n    | 46  | Explore                | explore               | None    |\n    | 47  | Explore Relax          | explore.relax         | None    |\n    | ... | ...                    | ...                   | ...     |\n    | 541 | LoFi Focus             | explore.focus.lowfi   | 30 mins |\n    +-----+------------------------+-----------------------+-------- +\n\n    $ brain gt 60\n    3ff0eab0-a5f6-11e6-a5c2-f11c700a6178\n\n    $ brain play 60\n    # opens a browser at:\n    #   https://stream.brain.fm/?tkn=3ff0eab0-a5f6-11e6-a5c2-f11c700a6178\n\n--------------------\n Override Endpoints\n--------------------\n\nFrom the cli you can override the api and stream endpoints with\n``--api-endpoint`` and ``--stream-endpoint`` respectively.  This is useful\nwhen the service switches endpoints but this library hasn't been updated to\nmatch.\n\nYou can also provide these as env variables\n``BRAINFM_API_ENDPOINT`` and ``BRAINFM_STREAM_ENDPOINT``\n\n============\n User-Agent\n============\n\nBy default the user agent is ``github.com/numberoverzero/brainfm``\nfollowed by the project ``__version__``.\nThere is also a packaged browser-like user-agent:\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e client = brainfm.Connection(...)\n    \u003e\u003e\u003e client.user_agent = brainfm.BROWSER\n\nInstead of filtering, maybe this will be a good metric\nfor customer interest in an official API :heart:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumberoverzero%2Fbrainfm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnumberoverzero%2Fbrainfm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumberoverzero%2Fbrainfm/lists"}