-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Trying to fetch directly from the API is too dangerous at this point, since the API is blocked - I've chosen to iterate on a GraphQL subtitles upload API - Trying the GraphQL mutation with Absinthe, I got a "No query document supplied" error - ```gql mutation SetVideoCaptions($captions: Upload!) { setVideoCaptions(videoId: 1, captions: $captions) { captions { text } } } ``` - Decided to upgrade Absinthe to see how that goes - [absinthe_ecto](https://github.com/absinthe-graphql/absinthe_ecto) is deprecated, so I'm looking to move to [dataloader](https://github.com/absinthe-graphql/dataloader) - Updated the dependencies, now looking to migrate the actual `assoc` calls
- Loading branch information
Showing
29 changed files
with
190 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
defmodule CF.Videos.CaptionsSrv1Parser do | ||
@moduledoc """ | ||
A captions parser for the srv1 format. | ||
""" | ||
|
||
require Logger | ||
import SweetXml | ||
|
||
def parse_file(content) do | ||
content | ||
|> SweetXml.xpath( | ||
~x"//transcript/text"l, | ||
text: ~x"./text()"s |> transform_by(&clean_text/1), | ||
start: ~x"./@start"s |> transform_by(&parse_float/1), | ||
duration: ~x"./@dur"os |> transform_by(&parse_float/1) | ||
) | ||
|> Enum.filter(fn %{text: text, start: start} -> | ||
start != nil and text != nil and text != "" | ||
end) | ||
end | ||
|
||
defp clean_text(text) do | ||
text | ||
|> String.replace("&", "&") | ||
|> HtmlEntities.decode() | ||
|> String.trim() | ||
end | ||
|
||
defp parse_float(val) do | ||
case Float.parse(val) do | ||
{num, _} -> num | ||
_ -> nil | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.