diff options
author | Jordan Bracco <href@random.sh> | 2022-12-20 00:21:54 +0000 |
---|---|---|
committer | Jordan Bracco <href@random.sh> | 2022-12-20 19:29:41 +0100 |
commit | 2d83df8b32bff7f0028923bb5b64dc0b55f20d03 (patch) | |
tree | 1207e67b5b15f540963db05e7be89f3ca950e724 /lib/lsg_irc/link_plugin/pdf.ex | |
parent | Nola rename, the end. pt 6. Refs T77. (diff) |
Nola rename: The Big Move, Refs T77
Diffstat (limited to 'lib/lsg_irc/link_plugin/pdf.ex')
-rw-r--r-- | lib/lsg_irc/link_plugin/pdf.ex | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/lib/lsg_irc/link_plugin/pdf.ex b/lib/lsg_irc/link_plugin/pdf.ex deleted file mode 100644 index 5f72ef5..0000000 --- a/lib/lsg_irc/link_plugin/pdf.ex +++ /dev/null @@ -1,39 +0,0 @@ -defmodule Nola.IRC.LinkPlugin.PDF do - require Logger - @behaviour Nola.IRC.LinkPlugin - - @impl true - def match(_, _), do: false - - @impl true - def post_match(_url, "application/pdf"<>_, _header, _opts) do - {:file, nil} - end - - def post_match(_, _, _, _), do: false - - @impl true - def post_expand(url, file, _, _) do - case System.cmd("pdftitle", ["-p", file]) do - {text, 0} -> - text = text - |> String.trim() - - if text == "" do - :error - else - basename = Path.basename(url, ".pdf") - text = "[#{basename}] " <> text - |> String.split("\n") - {:ok, text} - end - {_, 127} -> - Logger.error("dependency `pdftitle` is missing, please install it: `pip3 install pdftitle`.") - :error - {error, code} -> - Logger.warn("command `pdftitle` exited with status code #{code}:\n#{inspect error}") - :error - end - end - -end |