podcast-to-youtube 0.3.1 → 0.3.2

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 +25 -17
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecc3e03329b81238af59920c7a223912caa06092
4
- data.tar.gz: a3cb293ce84f99e56a1d03197b3ecd2879d2aaab
3
+ metadata.gz: 49743b759a5880b2f03bfdf892594aa57ddb5499
4
+ data.tar.gz: 0e0feecbddc1075abea7160eb6535afb3909f373
5
5
  SHA512:
6
- metadata.gz: b6b45fe665d9b3d1559083771b682b97ecee996b659c5c6afdf652ca4109ad45a7a398a3601b1043838c7f5e8fc747846bdb27991d0728385c186080aa402edd
7
- data.tar.gz: fcd57986a0dcf8a59d6e82fead2a1805ef32d5877ab7692ae3e42a648dda36c339d9c4b93dd631a153f0f49d30016be918d28f7e9c0f5138de6f09d56b0035c1
6
+ metadata.gz: 07684c3db91a2adc3c3ed7986f000a418b872d91165a21ac75c1e6b82605ede03b883cba7048d4537fee246210dc7aa50f06071792cfaa58adc1beeb0bb9ddf2
7
+ data.tar.gz: 2db9212492ef1142699d32da0819cb285278ec947437b09460b0d5c1a3bb2da0746b082428a6f57c1cc9477fd2eccfd65e59336eac460a50a1ff331edd21766d
@@ -34,32 +34,40 @@ class PodcastUploader
34
34
  def upload(podcast_feed_url, video_category_id, privacy = :private)
35
35
  feed = parse_feed podcast_feed_url
36
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
37
  video_title = "#{feed.title} - #{entry.title}"
42
- tags = %w(podcast)
43
-
44
- upload_video video_title video_description video_category_id privacy tags videofile
38
+ if !video_already_exists(video_title)
39
+ audiofile = download_asset entry.enclosure_url
40
+ coverart = download_asset entry.itunes_image
41
+ videofile = generate_videofile audiofile coverart
42
+ video_description = generate_video_description(entry, feed)
43
+ tags = %w(podcast)
44
+
45
+ upload_video video_title video_description video_category_id privacy tags videofile
46
+ else
47
+ puts "video #{video_title} already exists on Youtube. Skipping."
48
+ end
45
49
  end
46
50
  end
47
51
 
48
52
  private
49
53
 
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
58
- end
59
- @account.upload_video videofile, privacy_status: privacy, title: video_title, description: video_description, category_id: video_category_id, tags: tags
54
+ def refresh_authentication
55
+ if @account.authentication.expired?
56
+ authenticate_youtube_by_refresh_token
60
57
  end
61
58
  end
62
59
 
60
+ def upload_video(video_title, video_description, video_category_id, privacy, tags, videofile)
61
+ puts "uploading videofile to Youtube"
62
+ refresh_authentication
63
+ @account.upload_video videofile, privacy_status: privacy, title: video_title, description: video_description, category_id: video_category_id, tags: tags
64
+ end
65
+
66
+ def video_already_exists(video_title)
67
+ refresh_authentication
68
+ return @account.videos.any? {|video| video.title == video_title }
69
+ end
70
+
63
71
  def generate_videofile(audiofile, coverart)
64
72
  videofile = File.basename(audiofile, File.extname(audiofile)) + ".mkv"
65
73
  if !File.file?(videofile)
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.1
4
+ version: 0.3.2
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-14 00:00:00.000000000 Z
11
+ date: 2015-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: feedjira