podcast-to-youtube 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 07c96c0cb415c3f597c5f5ae182081fe937213fd
4
+ data.tar.gz: 690a01bd70481a7fd5b547cfb0e31d886aaaf144
5
+ SHA512:
6
+ metadata.gz: 676d0714a8e1bd28976e19bba64939dcbb491b49ef52905a04f4615ee07ae0d71b9184acb7abc493c7726a8ef2d5c4da7b82d049b4bb263bcf30bade6de0930b
7
+ data.tar.gz: 221fd50747c6c782a18f7a233cda2d880583728f8272409e0dac76f2d4e880b7234fee266ccdf5f26a3242ebf8fee10dd117a63aaec81a4765481849afc16ce2
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'podcast-to-youtube'
4
+
5
+ PodcastUploader.upload
@@ -0,0 +1,85 @@
1
+ # encoding: utf-8
2
+
3
+ require 'feedjira'
4
+ require 'yt'
5
+ require 'yaml'
6
+ require 'rubygems'
7
+ require 'json'
8
+
9
+ class PodcastUploader
10
+ def self.upload()
11
+
12
+ client_secret_file_path = 'client_secret.json'
13
+ if File.file?(client_secret_file_path)
14
+ client_secret = JSON.parse(File.read(client_secret_file_path))
15
+ else
16
+ raise "Please provide client_secret.json. This is required for the Youtube API authentication. More information can be found in the Readme."
17
+ end
18
+
19
+ video_category_id = '28'
20
+
21
+ puts "enter your podcast feed url and press enter"
22
+ url = gets.chomp
23
+ puts "parsing feed"
24
+ feed = Feedjira::Feed.fetch_and_parse url
25
+
26
+ puts "connecting to youtube account"
27
+ Yt.configure do |config|
28
+ config.client_id = client_secret['installed']['client_id']
29
+ config.client_secret = client_secret['installed']['client_secret']
30
+ end
31
+ redirect_uri = 'urn:ietf:wg:oauth:2.0:oob' # special redirect uri to make the user copy the auth_code to the application
32
+ puts "open this url in a browser"
33
+ puts Yt::Account.new(scopes: ['youtube'], redirect_uri: redirect_uri).authentication_url
34
+ puts "paste the authentication code here and press enter"
35
+ auth_code = gets.chomp
36
+ account = Yt::Account.new authorization_code: auth_code, redirect_uri: redirect_uri
37
+
38
+ feed.entries.reverse_each do |entry|
39
+
40
+ # Downlaod the audio file
41
+ puts "downloading audio file from #{entry.enclosure_url}"
42
+ downloadAudioCMD_status = system( "wget", "-c", "#{entry.enclosure_url}" )
43
+ audiofile = entry.enclosure_url.split('/').last
44
+
45
+ # Download the coverart
46
+ puts "downloading coverart from #{entry.itunes_image}"
47
+ downloadCoverartCMD_status = system( "wget", "-c", "#{entry.itunes_image}" )
48
+ coverart = entry.itunes_image.split('/').last
49
+
50
+ if(downloadCoverartCMD_status && downloadAudioCMD_status)
51
+ # convert to mkv format
52
+ videofile = File.basename(audiofile, File.extname(audiofile)) + ".mkv"
53
+ if !File.file?(videofile)
54
+ puts "generating videofile #{videofile}"
55
+ 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}" )
56
+ else
57
+ # file already exists
58
+ puts "videofile #{videofile} already exists. skipping ffmpeg renderning."
59
+ convertCMD_status = true
60
+ end
61
+
62
+ if(convertCMD_status)
63
+ # upload to youtube
64
+ video_description = "#{entry.itunes_summary}\n\nMehr Infos und Links zur Episode: #{entry.url}\nVeröffentlicht: #{entry.published}\nEpisode herunterladen (Audio): #{entry.url}\n\nPodcast Webseite: #{feed.url}\nPodcast Abonnieren: #{feed.url}\nPodcast Author: #{feed.itunes_author}"
65
+ video_title = "#{feed.title} - #{entry.title}"
66
+ if account.videos.any? {|video| video.title == video_title }
67
+ puts "do not upload video, as it is already online"
68
+ else
69
+ puts "uploading videofile to Youtube"
70
+ # refresh authentication if expired
71
+ if account.authentication.expired?
72
+ account = Yt::Account.new refresh_token: account.authentication.refresh_token
73
+ end
74
+ account.upload_video videofile, privacy_status: :private, title: video_title, description: video_description, category_id: video_category_id, tags: %w(podcast)
75
+ end
76
+ else
77
+ raise "generating videofile #{videofile} failed"
78
+ end
79
+ else
80
+ raise "downloading audiofile or coverart failed"
81
+ end
82
+ end
83
+
84
+ end
85
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: podcast-to-youtube
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Stefan Trauth
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: feedjira
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: yt
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.25'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.25'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ description: Take your existing podcast feed and upload it to Youtube. The script
56
+ will automatically generate video .mkv files from your audio files with the episode
57
+ image as a still image. As far as possible metadata from the podcast feed will be
58
+ added to the Youtube video. All uploaded videos are private by default, so you can
59
+ review them before publishing.
60
+ email: mail@stefantrauth.de
61
+ executables:
62
+ - podcast-to-youtube
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - bin/podcast-to-youtube
67
+ - lib/podcast-to-youtube.rb
68
+ homepage: https://github.com/funkenstrahlen/podcast-to-youtube
69
+ licenses:
70
+ - MIT
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 2.4.5.1
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: Ruby script to upload an existing podcast feed and to Youtube.
92
+ test_files: []