podcast-to-youtube 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/podcast-to-youtube.rb +40 -41
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57b82537f13f35c6432a322663f7360e910f9157
4
- data.tar.gz: 082524dcc9f62e39f7ff2ff2d1c9cd97ffca0e9e
3
+ metadata.gz: ecc3e03329b81238af59920c7a223912caa06092
4
+ data.tar.gz: a3cb293ce84f99e56a1d03197b3ecd2879d2aaab
5
5
  SHA512:
6
- metadata.gz: 29c53c0dd2944e10e94c9fea6b3031fa7e90bd6e4545fd43a05256a07707e04438c4fc7070f37bafeb76f873cacda22bf5ee47655176bd6eacf7b7a63075c0f2
7
- data.tar.gz: efb9857a5df38a23b5f7ea228909731a12bbe9af4885ec0bce6328f1f1dc92cfb4a5d7bd9e7358b8f95668851954f9c89cb67f0071f63853ab40136febfb3c71
6
+ metadata.gz: b6b45fe665d9b3d1559083771b682b97ecee996b659c5c6afdf652ca4109ad45a7a398a3601b1043838c7f5e8fc747846bdb27991d0728385c186080aa402edd
7
+ data.tar.gz: fcd57986a0dcf8a59d6e82fead2a1805ef32d5877ab7692ae3e42a648dda36c339d9c4b93dd631a153f0f49d30016be918d28f7e9c0f5138de6f09d56b0035c1
@@ -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
- # Downlaod the audio file
40
- puts "downloading audio file from #{entry.enclosure_url}"
41
- downloadAudioCMD_status = system( "wget", "-c", "#{entry.enclosure_url}" )
42
- audiofile = entry.enclosure_url.split('/').last
43
-
44
- # Download the coverart
45
- puts "downloading coverart from #{entry.itunes_image}"
46
- downloadCoverartCMD_status = system( "wget", "-c", "#{entry.itunes_image}" )
47
- coverart = entry.itunes_image.split('/').last
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
- if(convertCMD_status)
62
- # upload to youtube
63
- video_description = generate_video_description(entry, feed)
64
- video_title = "#{feed.title} - #{entry.title}"
65
- if @account.videos.any? {|video| video.title == video_title }
66
- puts "do not upload video, as it is already online"
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
- raise "downloading audiofile or coverart failed"
80
- end
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
- private
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.0
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-13 00:00:00.000000000 Z
11
+ date: 2015-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: feedjira