A music player that connects to your cloud/distributed storage.
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 78 lines 1.8 kB view raw
1module Queue exposing (EngineItem, Item, makeEngineItem, makeItem, makeTrackUrl) 2 3import Dict exposing (Dict) 4import List.Extra as List 5import Sources exposing (Source) 6import Sources.Processing exposing (HttpMethod(..)) 7import Sources.Services 8import Time 9import Tracks exposing (IdentifiedTrack, Tags, Track) 10 11 12 13-- 🌳 14 15 16type alias Item = 17 { manualEntry : Bool 18 , identifiedTrack : IdentifiedTrack 19 } 20 21 22type alias EngineItem = 23 { isCached : Bool 24 , isPreload : Bool 25 , progress : Maybe Float 26 , sourceId : String 27 , trackId : String 28 , trackTags : Tags 29 , trackPath : String 30 , url : String 31 } 32 33 34 35-- 🔱 36 37 38makeEngineItem : Bool -> Time.Posix -> List Source -> List String -> Dict String Float -> Track -> EngineItem 39makeEngineItem preload timestamp sources cachedTrackIds progressTable track = 40 { isCached = List.member track.id cachedTrackIds 41 , isPreload = preload 42 , progress = Dict.get track.id progressTable 43 , sourceId = track.sourceId 44 , trackId = track.id 45 , trackPath = track.path 46 , trackTags = track.tags 47 , url = makeTrackUrl timestamp sources track 48 } 49 50 51makeItem : Bool -> IdentifiedTrack -> Item 52makeItem isManualEntry identifiedTrack = 53 { manualEntry = isManualEntry 54 , identifiedTrack = identifiedTrack 55 } 56 57 58makeTrackUrl : Time.Posix -> List Source -> Track -> String 59makeTrackUrl timestamp sources track = 60 sources 61 |> List.find (.id >> (==) track.sourceId) 62 |> Maybe.map (makeTrackUrl_ timestamp track) 63 |> Maybe.withDefault "<missing-source>" 64 65 66 67-- ㊙️ 68 69 70makeTrackUrl_ : Time.Posix -> Track -> Source -> String 71makeTrackUrl_ timestamp track source = 72 Sources.Services.makeTrackUrl 73 source.service 74 timestamp 75 source.id 76 source.data 77 Get 78 track.path