View Source Id3vx (Id3vx v0.0.1-rc1)

Provides the API for interacting with ID3 tags and files that contain them.

examples

Examples

parse-from-file

Parse from file

iex> {:ok, tag} = Id3vx.parse_file("test/samples/beamradio32.mp3")
...> tag.version
3

encode-new-tag

Encode new tag

Creating tags is most easily done with the utilities in Id3vx.Tag.

iex> Id3vx.Tag.create(3)
...> |> Id3vx.Tag.add_text_frame("TIT1", "Title!")
...> |> Id3vx.encode_tag()
<<73, 68, 51, 3, 0, 0, 0, 0, 0, 27, 84, 73, 84, 49, 0, 0, 0, 17, 0, 0, 1, 254, 255, 0, 84, 0, 105, 0, 116, 0, 108, 0, 101, 0, 33, 0, 0>>

parse-from-binary

Parse from binary

iex> tag = Id3vx.Tag.create(3)
...>       |> Id3vx.Tag.add_text_frame("TIT1", "Title!")
...> tag_binary = Id3vx.encode_tag(tag)
...> {:ok, tag} = Id3vx.parse_binary(tag_binary)
...> tag.version
3

add-chapter-to-an-existing-id3-tag

Add Chapter to an existing ID3 tag

A Chapter often has a URL and image. You can use Id3vx.Tag.add_attached_picture for the picture.

iex> tag =
...> "test/samples/beamradio32.mp3"
...> |> Id3vx.parse_file!()
...> |> Id3vx.Tag.add_typical_chapter_and_toc(0, 60_000, 0, 12345,
...>   "A Great Title",
...>   fn chapter ->
...>     Id3vx.Tag.add_custom_url(
...>       chapter,
...>       "chapter url",
...>       "https://underjord.io"
...>     )
...>   end
...> )
...> tag.version
3

Link to this section Summary

Functions

Generate a tag binary from a provided Id3vx.Tag struct.

Find and returns the tag binary without parsing it.

Parse an ID3 tag from a binary.

Parse an ID3 tag from a binary.

Parse an ID3 tag from the given file path.

Parse an ID3 tag from the given file path.

Replace an existing ID3 tag in a file with the provided tag producing a new output file.

Replace an existing ID3 tag in a file with the provided tag producing a new output file.

Link to this section Functions

@spec encode_tag(tag :: Id3vx.Tag.t()) :: binary()

Generate a tag binary from a provided Id3vx.Tag struct.

Returns a binary.

Find and returns the tag binary without parsing it.

Mostly used in tests.

Parse an ID3 tag from a binary.

Returns an Id3vx.Tag struct or throws an Id3vx.Error.

Parse an ID3 tag from a binary.

Returns {:ok, Id3vx.Tag} struct or throws an {:error, Id3vx.Error}.

@spec parse_file!(path :: String.t()) :: Id3vx.Tag.t()

Parse an ID3 tag from the given file path.

It will open the file read-only and only read as many bytes as necessary.

Returns an Id3vx.Tag struct or throws an Id3vx.Error.

@spec parse_file(path :: String.t()) ::
  {:ok, Id3vx.Tag.t()}
  | {:error,
     %Id3vx.Error{__exception__: term(), context: term(), message: term()}}

Parse an ID3 tag from the given file path.

It will open the file read-only and only read as many bytes as necessary.

Returns {:ok, Id3vx.Tag} struct or throws an {:error, Id3vx.Error}.

Link to this function

replace_tag!(tag, infile_path, outfile_path)

View Source

Replace an existing ID3 tag in a file with the provided tag producing a new output file.

Returns :ok or throws an Id3vx.Error.

Link to this function

replace_tag(tag, infile_path, outfile_path)

View Source

Replace an existing ID3 tag in a file with the provided tag producing a new output file.

Returns :ok or {:error, Id3vx.Error}.