podcast-to-youtube 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/podcast-to-youtube.rb +40 -41
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecc3e03329b81238af59920c7a223912caa06092
|
4
|
+
data.tar.gz: a3cb293ce84f99e56a1d03197b3ecd2879d2aaab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6b45fe665d9b3d1559083771b682b97ecee996b659c5c6afdf652ca4109ad45a7a398a3601b1043838c7f5e8fc747846bdb27991d0728385c186080aa402edd
|
7
|
+
data.tar.gz: fcd57986a0dcf8a59d6e82fead2a1805ef32d5877ab7692ae3e42a648dda36c339d9c4b93dd631a153f0f49d30016be918d28f7e9c0f5138de6f09d56b0035c1
|
data/lib/podcast-to-youtube.rb
CHANGED
@@ -33,55 +33,54 @@ class PodcastUploader
|
|
33
33
|
|
34
34
|
def upload(podcast_feed_url, video_category_id, privacy = :private)
|
35
35
|
feed = parse_feed podcast_feed_url
|
36
|
-
|
37
36
|
feed.entries.reverse_each do |entry|
|
37
|
+
audiofile = download_asset entry.enclosure_url
|
38
|
+
coverart = download_asset entry.itunes_image
|
39
|
+
videofile = generate_videofile audiofile coverart
|
40
|
+
video_description = generate_video_description(entry, feed)
|
41
|
+
video_title = "#{feed.title} - #{entry.title}"
|
42
|
+
tags = %w(podcast)
|
43
|
+
|
44
|
+
upload_video video_title video_description video_category_id privacy tags videofile
|
45
|
+
end
|
46
|
+
end
|
38
47
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
if(downloadCoverartCMD_status && downloadAudioCMD_status)
|
50
|
-
# convert to mkv format
|
51
|
-
videofile = File.basename(audiofile, File.extname(audiofile)) + ".mkv"
|
52
|
-
if !File.file?(videofile)
|
53
|
-
puts "generating videofile #{videofile}"
|
54
|
-
convertCMD_status = system( "ffmpeg", "-loop", "1", "-r", "2", "-i", "#{coverart}", "-i", "#{audiofile}", "-vf", "scale=-1:1080", "-c:v", "libx264", "-preset", "slow", "-tune", "stillimage", "-crf", "18", "-c:a", "copy", "-shortest", "-pix_fmt", "yuv420p", "-threads", "0", "#{videofile}" )
|
55
|
-
else
|
56
|
-
# file already exists
|
57
|
-
puts "videofile #{videofile} already exists. skipping ffmpeg renderning."
|
58
|
-
convertCMD_status = true
|
48
|
+
private
|
49
|
+
|
50
|
+
def upload_video(video_title, video_description, video_category_id, privacy, tags, videofile)
|
51
|
+
if @account.videos.any? {|video| video.title == video_title }
|
52
|
+
puts "do not upload video, as it is already online"
|
53
|
+
else
|
54
|
+
puts "uploading videofile to Youtube"
|
55
|
+
# refresh authentication if expired
|
56
|
+
if @account.authentication.expired?
|
57
|
+
authenticate_youtube_by_refresh_token
|
59
58
|
end
|
59
|
+
@account.upload_video videofile, privacy_status: privacy, title: video_title, description: video_description, category_id: video_category_id, tags: tags
|
60
|
+
end
|
61
|
+
end
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
else
|
68
|
-
puts "uploading videofile to Youtube"
|
69
|
-
# refresh authentication if expired
|
70
|
-
if @account.authentication.expired?
|
71
|
-
authenticate_youtube_by_refresh_token
|
72
|
-
end
|
73
|
-
@account.upload_video videofile, privacy_status: privacy, title: video_title, description: video_description, category_id: video_category_id, tags: %w(podcast)
|
74
|
-
end
|
75
|
-
else
|
76
|
-
raise "generating videofile #{videofile} failed"
|
63
|
+
def generate_videofile(audiofile, coverart)
|
64
|
+
videofile = File.basename(audiofile, File.extname(audiofile)) + ".mkv"
|
65
|
+
if !File.file?(videofile)
|
66
|
+
puts "generating videofile #{videofile}"
|
67
|
+
if !system( "ffmpeg", "-loop", "1", "-r", "2", "-i", "#{coverart}", "-i", "#{audiofile}", "-vf", "scale=-1:1080", "-c:v", "libx264", "-preset", "slow", "-tune", "stillimage", "-crf", "18", "-c:a", "copy", "-shortest", "-pix_fmt", "yuv420p", "-threads", "0", "#{videofile}" )
|
68
|
+
raise "generating videofile #{videofile} from #{audiofile} and #{coverart} failed"
|
77
69
|
end
|
78
70
|
else
|
79
|
-
|
80
|
-
|
71
|
+
# file already exists
|
72
|
+
puts "videofile #{videofile} already exists. skipping ffmpeg renderning."
|
73
|
+
end
|
74
|
+
return videofile
|
81
75
|
end
|
82
|
-
end
|
83
76
|
|
84
|
-
|
77
|
+
def download_asset(url)
|
78
|
+
puts "downloading asset file from #{url}"
|
79
|
+
if !system( "wget", "-c", "#{url}" )
|
80
|
+
raise "downloading asset from #{url} failed"
|
81
|
+
end
|
82
|
+
return url.split('/').last
|
83
|
+
end
|
85
84
|
|
86
85
|
def authenticate_youtube_by_refresh_token
|
87
86
|
puts "reauthenticate youtube with refresh token"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: podcast-to-youtube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Trauth
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: feedjira
|