Copyright | (c) 2019-2021 Sam May |
---|---|
License | GPL-3.0-or-later |
Maintainer | ag@eitilt.life |
Stability | stable |
Portability | non-portable (requires libcdio) |
Safe Haskell | None |
Language | Haskell2010 |
Metadata is stored in a binary format both library-internally and on the disc.
Most audio archivists will recognize it as "those information fields in a CUE
file" (though there are other
formats
as well), and casual listeners will recognize it as the scrolling text that
you're always happy to see, on the rare times your music player shows it.
Little-used and even-less-known, however, is that a single disc can
theoretically contain metadata in up to eight different languages; because of
the complexity that introduces, it makes more sense to use a second monadic
interface than to try to provide a single monolithic datatype within Cdio
.
Synopsis
- data CdText a
- data CdTextError = CdTextError CdTextErrorType Text
- data CdTextErrorType
- data Info = Info {}
- emptyInfo :: Info
- data Genre
- data Language
- = UnknownLanguage
- | Albanian
- | Breton
- | Catalan
- | Croatian
- | Welsh
- | Czech
- | Danish
- | German
- | English
- | Spanish
- | Esperanto
- | Estonian
- | Basque
- | Faroese
- | French
- | Frisian
- | Irish
- | Gaelic
- | Galician
- | Icelandic
- | Italian
- | Lappish
- | Latin
- | Latvian
- | Luxembourgian
- | Lithuanian
- | Hungarian
- | Maltese
- | Dutch
- | Norwegian
- | Occitan
- | Polish
- | Portuguese
- | Romanian
- | Romansh
- | Serbian
- | Slovak
- | Slovenian
- | Finnish
- | Swedish
- | Turkish
- | Flemish
- | Wallon
- | Zulu
- | Vietnamese
- | Uzbek
- | Urdu
- | Ukrainian
- | Thai
- | Telugu
- | Tatar
- | Tamil
- | Tadzhik
- | Swahili
- | SrananTongo
- | Somali
- | Sinhalese
- | Shona
- | SerboCroatian
- | Ruthenian
- | Russian
- | Quechua
- | Pushtu
- | Punjabi
- | Persian
- | Papamiento
- | Oriya
- | Nepali
- | Ndebele
- | Marathi
- | Moldavian
- | Malaysian
- | Malagasay
- | Macedonian
- | Laotian
- | Korean
- | Khmer
- | Kazakh
- | Kannada
- | Japanese
- | Indonesian
- | Hindi
- | Hebrew
- | Hausa
- | Gurani
- | Gujurati
- | Greek
- | Georgian
- | Fulani
- | Dari
- | Churash
- | Chinese
- | Burmese
- | Bulgarian
- | Bengali
- | Bielorussian
- | Bambora
- | Azerbaijani
- | Assamese
- | Armenian
- | Arabic
- | Amharic
- cdText :: CdText a -> Cdio (Either CdTextError a)
- parseCdText :: ByteString -> CdText a -> IO (Either CdTextError a)
- withLanguage :: Language -> CdText a -> CdText a
- withIndex :: Word -> CdText a -> CdText a
- withAll :: CdText a -> CdText [Maybe a]
- runCdText :: Cdio -> CdText a -> IO (Either CdTextError a)
- language :: CdText Language
- languages :: Cdio [Maybe Language]
- firstTrack :: CdText Track
- lastTrack :: CdText Track
- info :: Maybe Track -> CdText Info
- discId :: CdText (Maybe Text)
- genre :: CdText (Maybe Genre, Maybe Text)
- cdTextRaw :: Cdio (Maybe ByteString)
Types
A computation within the environment of metadata (in a particular language) stored on a CD. The options for affecting that environment from within are limited by design, as this library is intended for reading discs rather than authoring them.
Instances
Monad CdText Source # | |
Functor CdText Source # | |
MonadFail CdText Source # | Wraps the text in a |
Defined in Sound.Libcdio.Read.CdText | |
Applicative CdText Source # | |
Alternative CdText Source # |
|
LibcdioLogger CdText Source # | |
MonadError CdTextError CdText Source # | |
Defined in Sound.Libcdio.Read.CdText throwError :: CdTextError -> CdText a # catchError :: CdText a -> (CdTextError -> CdText a) -> CdText a # |
data CdTextError Source #
Associates a well-typed error with human-readable context information.
Instances
Eq CdTextError Source # | |
Defined in Sound.Libcdio.Read.CdText (==) :: CdTextError -> CdTextError -> Bool # (/=) :: CdTextError -> CdTextError -> Bool # | |
Read CdTextError Source # | |
Defined in Sound.Libcdio.Read.CdText readsPrec :: Int -> ReadS CdTextError # readList :: ReadS [CdTextError] # readPrec :: ReadPrec CdTextError # readListPrec :: ReadPrec [CdTextError] # | |
Show CdTextError Source # | |
Defined in Sound.Libcdio.Read.CdText showsPrec :: Int -> CdTextError -> ShowS # show :: CdTextError -> String # showList :: [CdTextError] -> ShowS # | |
MonadError CdTextError CdText Source # | |
Defined in Sound.Libcdio.Read.CdText throwError :: CdTextError -> CdText a # catchError :: CdText a -> (CdTextError -> CdText a) -> CdText a # |
data CdTextErrorType Source #
Potential situations which may cause a computation to fail.
InvalidBlock Word | The requested language index is outside of the bounds accessible
by the library ( |
LanguageNotFound Language | The CdText data does not contain the requested language, or
|
BadBinaryRead | The binary data can not be parsed into a CdText object. |
NoCdText | The CD contains no CdText data. |
CdTextEmpty |
|
FreeformCdTextError Text | Escape hatch from structured typing to allow user-specified (and user-triggered) errors. |
Instances
Eq CdTextErrorType Source # | |
Defined in Sound.Libcdio.Read.CdText (==) :: CdTextErrorType -> CdTextErrorType -> Bool # (/=) :: CdTextErrorType -> CdTextErrorType -> Bool # | |
Read CdTextErrorType Source # | |
Defined in Sound.Libcdio.Read.CdText | |
Show CdTextErrorType Source # | |
Defined in Sound.Libcdio.Read.CdText showsPrec :: Int -> CdTextErrorType -> ShowS # show :: CdTextErrorType -> String # showList :: [CdTextErrorType] -> ShowS # |
Textual metadata describing a single track on a disc, or the disc itself.
Genres recognized in the CD Text standard.
Written languages recognized in the CD Text standard.
Instances
Bounded Language Source # | |
Enum Language Source # | |
Defined in Foreign.Libcdio.Types.Enums | |
Eq Language Source # | |
Ord Language Source # | |
Defined in Foreign.Libcdio.Types.Enums | |
Read Language Source # | |
Show Language Source # | |
Evaluation
parseCdText :: ByteString -> CdText a -> IO (Either CdTextError a) Source #
Given a binary stream, attempt to parse it as a CdText block and run the
given computation. Returns
if that parse fails.
At this top level, a Left
BadBinaryRead
specifically will almost always have
the same effect as running the computation directly.withIndex
0
Note that binary CdText dumps will frequently include four bytes at the
beginning indicating the size of the file; this implementation expects that
those bytes are not included. If your dump does indeed begin with them,
before passing the drop
4ByteString
to this function.
Before libcdio 0.94: Always returns Left
BadBinaryRead
withLanguage :: Language -> CdText a -> CdText a Source #
Try to use a specific language as the context for the given computation;
as this will frequently fail with LanguageNotFound
if given anything other
than English
, it is recommended that you provide a fallback with
<|>
or at least allow recovery with optional
. Note that
UnknownLanguage
will always fail.
withIndex :: Word -> CdText a -> CdText a Source #
Run the given computation over the data in a specific block. Fails with
InvalidBlock
if the index can't be accessed.
withAll :: CdText a -> CdText [Maybe a] Source #
Run the given computation over all of the accessible languages in the
CdText data. When successful, the resulting list can be associated exactly
with the list of languages
:
>>>
ls <- 'languages'
>>>
Right ls' <- 'cdText' $ 'withAll' 'language'
>>>
ls == ls'
True
runCdText :: Cdio -> CdText a -> IO (Either CdTextError a) Source #
Use a C-style Cdio
object as the base to run a Haskell-style
CdText
computation.
Note that some invariants of the monadic interface may not work as expected when used with the mutable objects, usually due to changing the active language block:
l <-language
cdio _ <-runCdText
cdio $withIndex
i g l' <-language
cdio (l == l') == undefined
Data
language :: CdText Language Source #
Get the language in which any info is currently being retrieved.
languages :: Cdio [Maybe Language] Source #
List every language with associated data in the CdText data associated
with the session. Drops any UnknownLanguage
values from the end
of the list. For a version which operates within the CdText
monad, the
construction
will have an identical effect.withAll
language
Before libcdio 2.1.0: Silently drops any Nothing
or
values, even in the middle of the list,
and only lists any single language a maximum of one time.Just
UnknownLanguage
firstTrack :: CdText Track Source #
The earliest track with any associated metadata in the current language.
Note that this may differ from minTrack
which gives
the first track on the disk, CDTEXT or not.
lastTrack :: CdText Track Source #
The final track with any associated metadata in the current language.
Note that this may differ from maxTrack
which gives
the last track on the disc, CDTEXT or not.
info :: Maybe Track -> CdText Info Source #
Retrieve the collection of data associated with a specific track, or if
Nothing
, the disc itself.