TwspaceDL

Download Twitter Space Audio

Dependency

Example

Download by space url

space = TwitterSpaceDL.new!(:space_url, "https://twitter.com/i/spaces/1OyJADqBEgDGb")
# download synchronously
TwitterSpaceDL.download(space)

# download asynchronously
TwitterSpaceDL.async_download(space, self())
# iex > flush
# {#PID<0.368.0>, %{download_pid: #PID<0.370.0>, space_id: "1OyJADqBEgDGb"}}
# {#PID<0.368.0>, %{space_id: "1OyJADqBEgDGb"}, :ok}
# :ok

Download by space id and display ffmpeg output

space = TwitterSpaceDL.new!(:space_id, "1OyJADqBEgDGb", show_ffmpeg_output: true)
# download synchronously
TwitterSpaceDL.download(space)

# download asynchronously
TwitterSpaceDL.async_download(space, self())
# iex > flush
# {#PID<0.368.0>, %{download_pid: #PID<0.370.0>, space_id: "1OyJADqBEgDGb"}}
# {#PID<0.368.0>, %{space_id: "1OyJADqBEgDGb"}, :ok}
# :ok

Download by space id, use custom filename template and save to download directory

space = TwitterSpaceDL.new!(:space_id, "1OyJADqBEgDGb",
  template: "space-%{title}-%{rest_id}-%{created_at}",
  save_dir: "./download")
# download synchronously
TwitterSpaceDL.download(space)

# download asynchronously
TwitterSpaceDL.async_download(space, self())
# iex > flush
# {#PID<0.368.0>, %{download_pid: #PID<0.370.0>, space_id: "1OyJADqBEgDGb"}}
# {#PID<0.368.0>, %{space_id: "1OyJADqBEgDGb"}, :ok}
# :ok

Init by username, use custom filename template and use plugin module

space = TwitterSpaceDL.new!(:user, "LaplusDarknesss",
  template: "space-%{title}-%{rest_id}",
  plugin_module: TwitterSpaceDL.Plugin.CLI)

# you can call this again to download new spaces (if space archive is available)
# download synchronously
TwitterSpaceDL.download(space)

# download asynchronously
TwitterSpaceDL.async_download(space, self())
# iex > flush
# {#PID<0.400.0>, %{download_pid: #PID<0.402.0>, username: "LaplusDarknesss"}}
# {#PID<0.400.0>, %{username: "LaplusDarknesss"}, [{"https://twitter.com/i/spaces/1mnGedeXloNKX", :ok}]}
# :ok

Optional arguments

Installation

If available in Hex, the package can be installed by adding twspace_dl to your list of dependencies in mix.exs:

def deps do
  [
    {:twspace_dl, "~> 0.1.1"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/twspace_dl.