Skip to content

jebjerg/streamfind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StreamFind

Types / Adding new providers

-- a search provider
searchXYZ :: Query -> IO Response

type Response = Either Error [Result]

data Result = Result
  { title       :: String
  , description :: Maybe String
  , url         :: Maybe String
  , price       :: Maybe Int
  , available   :: Bool
  , provider    :: String
  } deriving (Show)

-- helpers
eitherGetWith :: Options -> String -> IO EitherWWWResponse
-- reponseBody'

It's encouraged to use the ToResult typeclass, as you'll more often than not have a more detailed result from your provider. Keeping the (intermediary) type makes Result-fitting and the provider easier to maintain.

See DR.hs as an example.

Usage

See XMonad.hs as an example integration.

Snippit from Main.hs:

main = do
  q <- unwords <$> getArgs
  let backends = [searchDR]
  responses <- search q backends
  let errs = lefts responses
  let results = concat $ rights responses
  -- do something with reslts, and errors
  mapM_ (putStrLn . fmt) results
  mapM_ putStrLn errs

About

Search various streaming providers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published