brainfm icon indicating copy to clipboard operation
brainfm copied to clipboard

Stations sort/list

Open rocketinventor opened this issue 5 years ago • 3 comments

Hi @numberoverzero, I remember seeing a discussion somewhere about how to sort through the stations' list — I have been working on this issue, myself.

Almost all of the "stations" that are returned by brain ls have id, parent_id, and display_order tags that make it possible to sort and organize the stations (the same as the website).

This can be done automatically, by starting at 0 and recursively finding the children.

However, this method will leave many orphaned stations. This issue can be solved if you know the ids for the Station Categories...

I found them hardcoded into the app.bundle.js code:

var QUICK_RELAX = exports.QUICK_RELAX = 253;
var MEDITATE = exports.MEDITATE = 99;
var FOCUS = exports.FOCUS = 35;
var SLEEP = exports.SLEEP = 192;
var RECHARGE = exports.RECHARGE = 147;

and

var EXPLORE_FOCUS_ID = exports.EXPLORE_FOCUS_ID = 48;
var EXPLORE_RELAX_ID = exports.EXPLORE_RELAX_ID = 47;
var EXPLORE_SLEEP_ID = exports.EXPLORE_SLEEP_ID = 49;

rocketinventor avatar Jun 19 '20 16:06 rocketinventor

I made a program to sort through all of the channels and build a tree from them.

Here is the output:

Explore:

  Explore Focus [48]
     0) Classical Focus (30 minutes) [539] (48)
     0) LoFi Focus (30 minutes) [541] (48)
     1) Atmospheric Focus (30 minutes) [538] (48)
     2) Beach Focus (30 minutes) [53] (48)
     3) Chimes & Bowls Focus (30 minutes) [54] (48)
     4) Cinematic Music Focus (15 minutes) [300] (48)
     5) Drone Focus (30 minutes) [537] (48)
     6) Electronic Music Focus (30 minutes) [55] (48)
     7) Forest Focus (30 minutes) [56] (48)
     8) Grooves Focus (30 minutes) [536] (48)
     9) Nightsounds Focus (30 minutes) [57] (48)
     10) Piano Focus (30 minutes) [302] (48)
     11) Rain Focus (30 minutes) [58] (48)
     12) Relaxed (30 minutes) [34] (48)
     13) Study Focus (30 minutes) [540] (48)
     14) Thunder Focus (30 minutes) [59] (48)
     15) Underwater Focus (30 minutes) [61] (48)
     16) Wind Focus (30 minutes) [60] (48)

  Explore Relax [47]
     0) Ambient Music Relax [254] (47)
       1) 15 minutes [62] (254)
       2) 30 minutes [286] (254)
     1) Beach Relax [255] (47)
       1) 15 minutes [63] (255)
       2) 30 minutes [287] (255)
     2) Chimes & Bowls Relax [256] (47)
       1) 15 minutes [64] (256)
       2) 30 minutes [288] (256)
     3) Forest Relax [257] (47)
       1) 15 minutes [65] (257)
       2) 30 minutes [289] (257)
     4) Guided (20 minutes) [100] (47)
     5) Nightsounds Relax [258] (47)
       1) 15 minutes [66] (258)
       2) 30 minutes [290] (258)
     6) Rain Relax [259] (47)
       1) 15 minutes [67] (259)
       2) 30 minutes [291] (259)
     7) Thunder Relax [260] (47)
       1) 15 minutes [68] (260)
       2) 30 minutes [292] (260)
     8) Underwater Relax [261] (47)
       1) 15 minutes [69] (261)
       2) 30 minutes [293] (261)
     9) Wind Relax [262] (47)
       1) 15 minutes [70] (262)
       2) 30 minutes [294] (262)

  Explore Sleep [49]
     0) Ambient Music Sleep [71] (49)
       0) Recharge [149] (71)
       * 1) 15 minutes [179] (149)
       * 2) 30 minutes [164] (149)
       * 3) 45 minutes [80] (149)
       0) Sleep [194] (71)
       * 1) 6 hours (360 minutes) [209] (194)
       * 2) 7 hours (420 minutes) [224] (194)
       * 3) 8 hours (480 minutes) [88] (194)
     1) Beach Sleep [72] (49)
       0) Recharge [150] (72)
       * 1) 15 minutes [180] (150)
       * 2) 30 minutes [165] (150)
       * 3) 45 minutes [81] (150)
       0) Sleep [195] (72)
       * 1) 6 hours (360 minutes) [210] (195)
       * 2) 7 hours (420 minutes) [225] (195)
       * 3) 8 hours (480 minutes) [89] (195)
     3) Forest Sleep [74] (49)
       0) Recharge [151] (74)
       * 1) 15 minutes [181] (151)
       * 2) 30 minutes [166] (151)
       * 3) 45 minutes [83] (151)
       0) Sleep [196] (74)
       * 1) 6 hours (360 minutes) [211] (196)
       * 2) 7 hours (420 minutes) [226] (196)
       * 3) 8 hours (480 minutes) [91] (196)
     4) Nightsounds Sleep [75] (49)
       0) Recharge [152] (75)
       * 1) 15 minutes [182] (152)
       * 2) 30 minutes [167] (152)
       * 3) 45 minutes [84] (152)
       0) Sleep [197] (75)
       * 1) 6 hours (360 minutes) [212] (197)
       * 2) 7 hours (420 minutes) [227] (197)
       * 3) 8 hours (480 minutes) [92] (197)
     5) Rain Sleep [76] (49)
       0) Recharge [156] (76)
       * 1) 15 minutes [186] (156)
       * 2) 30 minutes [171] (156)
       * 3) 45 minutes [97] (156)
       0) Sleep [198] (76)
       * 1) 6 hours (360 minutes) [213] (198)
       * 2) 7 hours (420 minutes) [228] (198)
       * 3) 8 hours (480 minutes) [93] (198)
     6) Thunder Sleep [77] (49)
       0) Recharge [153] (77)
       * 1) 15 minutes [183] (153)
       * 2) 30 minutes [168] (153)
       * 3) 45 minutes [85] (153)
       0) Sleep [199] (77)
       * 1) 6 hours (360 minutes) [214] (199)
       * 2) 7 hours (420 minutes) [229] (199)
       * 3) 8 hours (480 minutes) [94] (199)
     7) Underwater Sleep [78] (49)
       0) Recharge [154] (78)
       * 1) 15 minutes [184] (154)
       * 2) 30 minutes [169] (154)
       * 3) 45 minutes [86] (154)
       0) Sleep [200] (78)
       * 1) 6 hours (360 minutes) [215] (200)
       * 2) 7 hours (420 minutes) [230] (200)
       * 3) 8 hours (480 minutes) [95] (200)
     8) Wind Sleep [79] (49)
       0) Recharge [155] (79)
       * 1) 15 minutes [185] (155)
       * 2) 30 minutes [170] (155)
       * 3) 45 minutes [87] (155)
       0) Sleep [201] (79)
       * 1) 6 hours (360 minutes) [216] (201)
       * 2) 7 hours (420 minutes) [231] (201)
       * 3) 8 hours (480 minutes) [96] (201)

Home Stations:

  Home Quick_Relax [253]
     1) 15 minutes [32] (253)
     2) 30 minutes [285] (253)

  Home Meditate [99]
     0) 30 minutes [101] (99)
     0) 15 minutes [299] (99)

  Home Focus [35]

  Home Sleep [192]
     1) 6 hours (360 minutes) [207] (192)
     2) 7 hours (420 minutes) [222] (192)
     3) 8 hours (480 minutes) [42] (192)

No Parent:
   2) Sleep (45 minutes) [36]
     1) Recharge [147] (36)
       1) 15 minutes [177] (147)
       2) 30 minutes [162] (147)
       3) 45 minutes [41] (147)

Orphans: 3
   0) Explore [46]
   0) Relax [98]
   0) Intense (30 minutes) [535] (33)

It's worth noting that "stations" which are lacking a duration option will still allow you to make tokens, but the tokens will give a 404 when turned into a URL (using the make_stream_url function).

rocketinventor avatar Jun 19 '20 16:06 rocketinventor

It should not be too difficult to add a categories and substations parameter to the CLI.

i.e.

$ brain browse lists
Home
Explore

$ brain browse Explore

Focus | 48
Relax | 47
Sleep | 49

$ brain substations 48

Classical Focus | 539
LoFi Focus | 541
Atmospheric Focus | 538
Beach Focus | 53
Chimes & Bowls Focus | 54
Cinematic Music Focus | 300
Drone Focus | 537
Electronic Music Focus | 55
Forest Focus | 56
Grooves Focus | 536
Nightsounds Focus | 57
Piano Focus | 302
Rain Focus | 58
Relaxed | 34
Study Focus | 540
Thunder Focus | 59
Underwater Focus | 61
Wind Focus | 60

rocketinventor avatar Jun 19 '20 16:06 rocketinventor

First, nice work building the graph automatically! That's not something you want to do by hand.

I don't want to start parsing the app bundle much because -- aside from brittle code -- I don't know how account feature flags can modify those values. For example, omitting or re-parenting station ids would be a silent failure. Imagine a user is part of A/B testing a station being listed as "focus" vs "deep sleep" by changing ids.

I agree that it would be nice to have some ability to see structure instead of a flat list though. Is string parsing the station name going to be too terrible here?

numberoverzero avatar Jun 26 '20 21:06 numberoverzero