brain.fm的非官方python api

brainfm的Python项目详细描述


Connection类公开三个操作:loginlist_stationsget_token。 如果您需要其他操作,请打开问题。

此客户端需要Python3.5+。

cli快速启动

$ pip install brainfm
$ brain init
Email: user@gdomain.com
Password: <hidden>
Repeat for confirmation: <hidden>

Add the following to your .profile, .bashrc, or equivalent:

    export BRAINFM_SID="s%3...s0xo"
$ # <commands to modify and reload profile>
$ brain play 300

库快速启动

pip install brainfm
>>> importbrainfm>>> client=brainfm.Connection()>>> client.login("your@email.here","hunter2")>>> client.list_stations()[{'name': 'Cinematic Music Focus', 'id': 300,
  'string_id': 'explore.focus.cinematic'},
 {'name': 'Beach Focus', 'id': 53,
  'string_id': 'explore.focus.beach'},
 ...]
>>> token=client.get_token(53)>>> token'63f4b59b-93f4-45e6-b0c2-eb6b1582fb96'
>>> brainfm.build_stream_url(token)'https://stream.brain.fm/?tkn=63f4b59b-93f4-45e6-b0c2-eb6b1582fb96'

现在,使用该标记打开流:

https://stream.brain.fm/?tkn=63f4b59b-93f4-45e6-b0c2-eb6b1582fb96

cli

期望存在一个名为 BealfMssid 的环境变量。 您可以使用brain init生成一个:

$ brain init
Email: user@gdomain.com
Password: <hidden>
Repeat for confirmation: <hidden>

Add the following to your .profile, .bashrc, or equivalent:

    export BRAINFM_SID="s%3...s0xo"

用法:

$ brain ls
+Available Stations------------+---------------------------+
| id  | name                   | string_id                 |
+-----+------------------------+---------------------------+
| 34  | Relaxed Focus          | explore.relaxed           |
| 53  | Beach Focus            | explore.focus.beach       |
| 54  | Chimes & Bowls Focus   | explore.focus.bells       |
| 55  | Electronic Music Focus | explore.focus.electronic  |
| ... | ...                    | ...                       |
| 262 | Wind Relax             | explore.relax.wind        |
| 300 | Cinematic Music Focus  | explore.focus.cinematic   |
+-----+------------------------+---------------------------+

$ brain gt 60
3ff0eab0-a5f6-11e6-a5c2-f11c700a6178

$ brain play 60
# opens a browser at:
#   https://stream.brain.fm/?tkn=3ff0eab0-a5f6-11e6-a5c2-f11c700a6178

用户代理

默认情况下,用户代理是github.com/numberoverzero/brainfm 然后是项目__version__。 还有一个类似浏览器的打包用户代理:

>>> client=brainfm.Connection(...)>>> client.user_agent=brainfm.BROWSER

与其过滤,也许这是一个很好的度量 对于客户对官方API的兴趣:heart:

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Spring框架服务单元测试   在Java中遍历hashmaps的hashmap以检索字符串值   如何使用CodeQL检查Java注释是否具有特定属性?   java为什么在Spring Boot中访问此资源而不是登录弹出窗口需要始终获得完全身份验证   处理将多集计数转换为列表的过程   java另一个线性布局,没有出现按钮   eclipse Java映像加载未显示在jar中   java Junit类无法加载基本测试类ApplicationContext   java如何在main中使用my getvalues()方法打印列表   java Sonar,S128:切换案例应该以无条件的“中断”语句结束,而不是继续   java从socket读取字符串错误连接重置错误   java使用新数据刷新任意图表饼图   java通过异步运行lambda访问方法参数   java错误的结果一旦我处理try and catch