Something went wrong. Try again.
A music player that connects to your cloud/distributed storage. forked from tokono.ma/diffuse
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121module Sources exposing (..)
import Conditional exposing (..)import Dict exposing (Dict)import Json.Decodeimport Time
-- 🌳
type alias Source = { id : String , data : SourceData , directoryPlaylists : Bool , enabled : Bool , service : Service }
-- PIECES
type alias Property = { key : String , label : String , placeholder : String , password : Bool }
type alias SourceData = Dict String String
-- SERVICES
type Service = AmazonS3 | AzureBlob | AzureFile | Dropbox | Google | Ipfs | WebDav
serviceDictionary : Dict String ServiceserviceDictionary = Dict.fromList [ ( "amazons3", AmazonS3 ) , ( "amazon_s3", AmazonS3 ) , ( "azureblob", AzureBlob ) , ( "azure_blob", AzureBlob ) , ( "azurefile", AzureFile ) , ( "azure_file", AzureFile ) , ( "dropbox", Dropbox ) , ( "google", Google ) , ( "ipfs", Ipfs ) , ( "webdav", WebDav ) , ( "web_dav", WebDav ) ]
serviceDecoder : Json.Decode.Decoder ServiceserviceDecoder = Json.Decode.andThen (\string -> serviceDictionary |> Dict.get string |> Maybe.map Json.Decode.succeed |> Maybe.withDefault (Json.Decode.fail "Invalid source kind") ) Json.Decode.string
--- 🔱
enabledSourceIds : List Source -> List StringenabledSourceIds = List.filterMap (\s -> ifThenElse s.enabled (Just s.id) Nothing)
setProperId : Int -> Time.Posix -> Source -> SourcesetProperId n time source = { source | id = String.fromInt (Time.posixToMillis time) ++ String.fromInt n }
worksOffline : Source -> BoolworksOffline source = case source.service of AmazonS3 -> False
AzureBlob -> False
AzureFile -> False
Dropbox -> False
Google -> False
Ipfs -> True
WebDav -> source.data |> Dict.get "url" |> Maybe.map (\u -> String.contains "localhost" u || String.contains "127.0.0.1" u) |> Maybe.withDefault False