Current section

44 Versions

Jump to

Compare versions

8 files changed
+24 additions
-6 deletions
  @@ -7,7 +7,7 @@ Feel free to fork this project, as it was released under the MIT license.
7 7
8 8 # Fluminus
9 9
10 - [![Build Status](https://travis-ci.com/indocomsoft/fluminus.svg?branch=master)](https://travis-ci.com/indocomsoft/fluminus)
10 + ![Build Status](https://github.com/indocomsoft/fluminus/workflows/Elixir%20CI/badge.svg)
11 11 [![Coverage Status](https://coveralls.io/repos/github/indocomsoft/fluminus/badge.svg?branch=master)](https://coveralls.io/github/indocomsoft/fluminus?branch=master)
12 12
13 13 <sup><sub>F LumiNUS! IVLE ftw! Why fix what ain't broken?!</sub></sup>
  @@ -52,9 +52,14 @@
52 52 {<<"optional">>,false},
53 53 {<<"repository">>,<<"hexpm">>},
54 54 {<<"requirement">>,<<"~> 1.4">>}],
55 + [{<<"app">>,<<"certifi">>},
56 + {<<"name">>,<<"certifi">>},
57 + {<<"optional">>,false},
58 + {<<"repository">>,<<"hexpm">>},
59 + {<<"requirement">>,<<"~> 2.5">>}],
55 60 [{<<"app">>,<<"jason">>},
56 61 {<<"name">>,<<"jason">>},
57 62 {<<"optional">>,false},
58 63 {<<"repository">>,<<"hexpm">>},
59 64 {<<"requirement">>,<<"~> 1.1">>}]]}.
60 - {<<"version">>,<<"2.2.7">>}.
65 + {<<"version">>,<<"2.2.8">>}.
  @@ -15,6 +15,9 @@ defmodule Fluminus.API.Module.ExternalMultimedia do
15 15 %__MODULE__{id: id, name: name, children: nil}
16 16 end
17 17
18 + @doc """
19 + Loads the children of a given `#{__MODULE__}` struct.
20 + """
18 21 @spec get_children(__MODULE__.t(), Authorization.t()) :: {:ok, [Child.t()]} | {:error, any()}
19 22 def get_children(%__MODULE__{id: id}, auth = %Authorization{}) do
20 23 uri = "/lti/Launch/mediaweb?context_id=#{id}"
  @@ -15,6 +15,9 @@ defmodule Fluminus.API.Module.ExternalMultimedia.Child do
15 15 %__MODULE__{viewer_url: viewer_url, name: name, client: client}
16 16 end
17 17
18 + @doc """
19 + Obtains the download url for a given file in an external multimedia channel's child.
20 + """
18 21 @spec get_download_url(__MODULE__.t()) :: {:ok, String.t()} | {:error, any()}
19 22 def get_download_url(%__MODULE__{viewer_url: viewer_url, client: client}) do
20 23 with {:ok, client, _, %{status_code: 200, body: body}} <- HTTPClient.get(client, viewer_url),
  @@ -28,6 +31,12 @@ defmodule Fluminus.API.Module.ExternalMultimedia.Child do
28 31 end
29 32 end
30 33
34 + @doc """
35 + Downloads the given file in an external multinedia channel's child to the location specified
36 + by `path`.
37 +
38 + This function will return `{:error, :exists}` if the file already exists in the given `path`
39 + """
31 40 @spec download(__MODULE__.t(), String.t(), bool()) :: :ok | {:error, :exists | any()}
32 41 def download(child = %__MODULE__{name: name}, path, verbose) do
33 42 destination = Path.join(path, Util.sanitise_filename(name) <> ".mp4")
  @@ -61,7 +61,7 @@ defmodule Fluminus.HTTPClient do
61 61 when method in @supported_methods and is_binary(url) and is_binary(body) and is_list(headers) do
62 62 headers = generate_headers(client, headers)
63 63
64 - case HTTPoison.request(method, url, body, headers, recv_timeout: 10_000) do
64 + case HTTPoison.request(method, url, body, headers, recv_timeout: 10_000, ssl: [cacerts: :certifi.cacerts()]) do
65 65 {:ok, response = %HTTPoison.Response{headers: headers}} ->
66 66 updated_client = update_cookies(client, response)
67 67 flattened_headers = headers |> Enum.map(fn {key, value} -> {String.downcase(key), value} end) |> Map.new()
Loading more files…