Permalink
Browse files

added background job

  • Loading branch information...
oblakeerickson committed Aug 30, 2018
1 parent 14b17f8 commit 06cfa9052277725a94614e4b2310e5fc0102380c
@@ -22,6 +22,7 @@ gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
gem 'mechanize'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
@@ -72,12 +72,17 @@ GEM
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
connection_pool (2.2.2)
crass (1.0.4)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
erubi (1.7.1)
execjs (2.7.0)
ffi (1.9.25)
globalid (0.4.1)
activesupport (>= 4.2.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (1.1.0)
concurrent-ruby (~> 1.0)
io-like (0.3.0)
@@ -95,16 +100,32 @@ GEM
mini_mime (>= 0.1.1)
marcel (0.3.2)
mimemagic (~> 0.3.2)
mechanize (2.7.6)
domain_name (~> 0.5, >= 0.5.1)
http-cookie (~> 1.0)
mime-types (>= 1.17.2)
net-http-digest_auth (~> 1.1, >= 1.1.1)
net-http-persistent (>= 2.5.2)
nokogiri (~> 1.6)
ntlm-http (~> 0.1, >= 0.1.1)
webrobots (>= 0.0.9, < 0.2)
method_source (0.9.0)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mimemagic (0.3.2)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
minitest (5.11.3)
msgpack (1.2.4)
multi_json (1.13.1)
net-http-digest_auth (1.4.1)
net-http-persistent (3.0.0)
connection_pool (~> 2.2)
nio4r (2.3.1)
nokogiri (1.8.4)
mini_portile2 (~> 2.3.0)
ntlm-http (0.1.1)
public_suffix (3.0.3)
puma (3.12.0)
rack (2.0.5)
@@ -177,11 +198,15 @@ GEM
thread_safe (~> 0.1)
uglifier (4.1.18)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
web-console (3.6.2)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
webrobots (0.1.2)
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
@@ -199,6 +224,7 @@ DEPENDENCIES
coffee-rails (~> 4.2)
jbuilder (~> 2.5)
listen (>= 3.0.5, < 3.2)
mechanize
puma (~> 3.11)
rails (~> 5.2.1)
sass-rails (~> 5.0)
@@ -6,6 +6,7 @@ def new
def create
@link = Link.new(link_params)
puts @link.url
ProcessVideoJob.perform_later @link.url
redirect_to :action => 'new'
end

@@ -0,0 +1,22 @@
require 'fileutils'

class ProcessVideoJob < ApplicationJob
queue_as :default

def perform(*args)
system "youtube-dl -o 'tmp/%(title)s.%(ext)s' --restrict-filenames --extract-audio --audio-format mp3 #{args[0]}"
file = Dir["tmp/*.mp3"][0]

a = Mechanize.new
login_page = a.get('https://overcast.fm/login')
my_page = login_page.form do |form|
form.email = AudioGrabApp::Application.credentials.overcast[:username]
form.password = AudioGrabApp::Application.credentials.overcast[:password]
end.submit
upload_page = a.click(my_page.link_with(:text => /ploads/))
upload_page.form_with(:method => 'POST') do |upload_form|
upload_form.file_uploads.first.file_name = file
end.submit
File.delete file
end
end
@@ -1 +1 @@
Y4bBaoGaYGLICEZGN00j2IdPCpCAAmG+QI9BusH7iFOyhbEUO5INt4JB4HhfMGziWhUT9S+ZQebWzfUSAivPlUmgAiC1h8NGLlq1Hc/nWn+wKkEYwgD2GprLfpBpSNel+R9hG54mCBiOqPLOJ9/zDv5deYccrh2MMzCwR6xN6sHPokEPkFexgjUjEot3SAvA3MM28luODjFJ2+mBbQFk1SDf4lA4yn+8PtXRt27+LtvQkhFN0miFj8ASW3Y9A3/wjNhOtP8scwMY7GvsXexbeHEfnR+9dWpl4P+/dGhHOJKWCVphkuhfRrgYZR8+F9md3DkC+GkrVJR+9gLyFj2pYOceT/QVHs8RE5PmfTw94YYoIhQyfESCQ8/9nUekl+iQsWTTQ8LmYTECvCRRPEDJUyUaiLCrfvmiUCF5--BfB8K82sVunUomK1--m63bFygIr4soDtd3iaAuDQ==
DlwQxnAKWfXQ3YB4LZtHs/7wRJ6okXo+vL6Ko4Ep8DhpdF/ClEVuA5A8hmVYQ2/yV+Hrxq7E5KJyDLW4Or8xFGYA9CfXVQpdC3yo1A3tyIK43AOOczfuuTEGp/vt8Fd6GFDkUga8itFMcQ/C/NZunfDl7NucqvezA+W/mbZmHrL/kVHLwAq6NoMOvckeR+ZWOOXjBvCRTr5ZSKBEQ7gDNKeEdBCTO7nkUPAW80eXOJfNKxvUaokhNwqcjN/qV25989yKtS3pfYFhOzuZd5o9QrO6VUAj1A/XFRHv6UF3lfbJEA7o1a4Nw1Bs34jYW7SEwWqP1D8sZStbI6bOcoVEKAqlnGd1ncmxkpErtgDyUo/AEqDWFpguNnd79EVB9w1kNtIxY/Mk8nfmo6wxk9Ddn4Jc8TiwQJQBd2G7G5uFVfh76h1WrfM=--MhltdMaCGGGPYvXK--XpWwGVZWZecCuJ78ly9dSg==
@@ -0,0 +1,7 @@
require 'test_helper'

class ProcessVideoJobTest < ActiveJob::TestCase
# test "the truth" do
# assert true
# end
end

0 comments on commit 06cfa90

Please sign in to comment.