Skip to content

Instantly share code, notes, and snippets.

@nickgartmann
Last active December 21, 2015 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickgartmann/d2a4b8c78fb9c9323ec1 to your computer and use it in GitHub Desktop.
Save nickgartmann/d2a4b8c78fb9c9323ec1 to your computer and use it in GitHub Desktop.
defmodule Mix.Tasks.FetchAllVideos do
use Mix.Task
def run(_) do
Day9tv.Repo.start_link
{:ok, items, next_page_token} = Day9tv.YouTube.playlist_items("UUaxar6TBM-94_ezoS00fLkA")
Enum.each items, fn(item) ->
changeset = Day9tv.Video.create_from_youtube(item)
Day9tv.Repo.insert!(changeset)
end
end
end
lib/mix/fetch_videos.ex:5: warning: variable next_page_token is unused
Compiled lib/mix/fetch_videos.ex
Generated day9tv app
14:46:52.337 [debug] BEGIN [] OK query=76.7ms queue=5.7ms
14:46:52.358 [debug] INSERT INTO "videos" ("inserted_at", "updated_at", "description", "episode_id", "large_thumbnail_url", "medium_thumbnail_url", "published_at", "small_thumbnail_url", "title", "youtube_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING "id" [{{2015, 12, 21}, {20, 46, 52, 0}}, {{2015, 12, 21}, {20, 46, 52, 0}}, "By popular demand, and by demand of catbert, I'll be playing SOMA. Let's see how far I can make it through w/o running away weeping.\n\nMy Website: http://day9.tv/\nMe on Twitter: http://twitter.com/day9tv/\nFind me on Facebook: http://www.facebook.com/day9tv/\nFancy Day[9] Swag: http://day9.tv/store/", nil, "https://i.ytimg.com/vi/ziZDwMSHoSI/hqdefault.jpg", "https://i.ytimg.com/vi/ziZDwMSHoSI/mqdefault.jpg", {{2015, 12, 21}, {16, 16, 30, 0}}, "https://i.ytimg.com/vi/ziZDwMSHoSI/default.jpg", "Day[9]'s Day Off - SOMA P3", "ziZDwMSHoSI"] ERROR query=4.2ms
** (exit) exited in: :gen_server.call(#PID<0.213.0>, {:query, #Reference<0.0.1.2581>, 15000}, 5000)
** (EXIT) no process
(postgrex) lib/postgrex/connection.ex:97: Postgrex.Connection.query/4
lib/ecto/adapters/postgres/connection.ex:31: Ecto.Adapters.Postgres.Connection.query/4
(stdlib) timer.erl:197: :timer.tc/3
lib/ecto/adapters/sql.ex:262: Ecto.Adapters.SQL.query/7
lib/ecto/pool.ex:149: Ecto.Pool.run/4
lib/ecto/adapters/sql.ex:247: Ecto.Adapters.SQL.query/6
lib/ecto/adapters/sql.ex:625: Ecto.Adapters.SQL.rollback/7
lib/ecto/pool.ex:244: Ecto.Pool.outer_transaction/6
lib/ecto/adapters/sql.ex:551: Ecto.Adapters.SQL.transaction/3
(elixir) lib/enum.ex:579: Enum."-each/2-lists^foreach/1-0-"/2
(elixir) lib/enum.ex:579: Enum.each/2
(mix) lib/mix/task.ex:291: Mix.Task.run_alias/3
(mix) lib/mix/task.ex:243: Mix.Task.run/2
(mix) lib/mix/cli.ex:55: Mix.CLI.run_task/2
(elixir) lib/code.ex:363: Code.require_file/2
shell returned 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment