TwitterSpaceDL (twspace_dl v0.1.1) View Source

Twitter Space Audio Downloader

Link to this section Summary

Functions

Download Twitter Space audio recording asynchronously

Returns a specification to start this module under a supervisor.

Download Twitter Space audio recording

Link to this section Functions

Link to this function

async_download(self_pid, callback_pid)

View Source

Download Twitter Space audio recording asynchronously

Returns a specification to start this module under a supervisor.

See Supervisor.

Download Twitter Space audio recording

Link to this function

new(source, source_arg, opts \\ default_opts())

View Source

New Twitter Space downloader

Please check new! for full information

Example

Download by space url

{:ok, space} = TwitterSpaceDL.new(:space_url, "https://twitter.com/i/spaces/1OyJADqBEgDGb")
TwitterSpaceDL.download(space)
Link to this function

new!(source, source_arg, opts \\ default_opts())

View Source

New Twitter Space downloader

  • source: specify the space source

    • :space_url.

      For example, "https://twitter.com/i/spaces/1OyJADqBEgDGb"

    • :space_id. For example, "1OyJADqBEgDGb"

  • opts: keyword options

    • show_ffmpeg_output: forward FFmpeg output to IO.puts

      Default value: false

    • save_dir: set download directory Default value: __DIR__

    • template: filename template Default value: "%{title}". Valid keys are:

      • title.
      • created_at.
      • ended_at.
      • rest_id.
      • started_at.
      • total_participated.
      • total_replay_watched.
      • updated_at.
    • plugin_module: name of the plugin module. The module should implement TwitterSpaceDL.Plugin

Return: pid

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