feedme_youtubes 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +2 -0
- data/README.md +7 -0
- data/Rakefile +1 -0
- data/bin/feedme +12 -0
- data/feedme_youtubes.gemspec +23 -0
- data/lib/feedme_youtubes.rb +105 -0
- data/lib/feedme_youtubes/version.rb +3 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1c24b34e8cb9aa4d39fae45024b90c81df697a9e
|
4
|
+
data.tar.gz: 85a843feb42cfc2fd06dc2a8f11482e1bb0bdbf8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6aa0127a65cc603031d48b89407c2c0610528f966a0a018274e0e7a6b865180db6dc70bd7be6636560b4ebe5d663f0b9686a3688a458747269d5ce8c368602df
|
7
|
+
data.tar.gz: 5cbc2596ee687f8c3a5dea820c87864ea69a4d9aff83eead1c8aca7856cd1725a01d88cef213402da110a68919bb004a0a683c457513ca15d9748d274ab5dbd6
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/feedme
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'feedme_youtubes/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "feedme_youtubes"
|
8
|
+
spec.version = FeedmeYoutubes::VERSION
|
9
|
+
spec.authors = ["Rob Wilson"]
|
10
|
+
spec.email = ["roobert@gmail.com"]
|
11
|
+
spec.summary = "fetch youtube feeds"
|
12
|
+
spec.description = "fetch youtube feeds!"
|
13
|
+
spec.homepage = "http://github.com/roobert/feedme_youtubes"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "feedme_youtubes/version"
|
4
|
+
require 'nokogiri'
|
5
|
+
require 'open-uri'
|
6
|
+
require 'awesome_print'
|
7
|
+
require 'youtube_dl'
|
8
|
+
require 'active_support/hash_with_indifferent_access'
|
9
|
+
|
10
|
+
# TODO:
|
11
|
+
# ncurses that launches mplayer (cos nice interface..)
|
12
|
+
# web interface on sinatra app with link to web page...
|
13
|
+
|
14
|
+
class FeedmeYoutubes
|
15
|
+
def initialize(hash)
|
16
|
+
@config = ActiveSupport::HashWithIndifferentAccess.new(hash)
|
17
|
+
@feeds = Feeds.new(@config[:authors])
|
18
|
+
end
|
19
|
+
|
20
|
+
def update
|
21
|
+
@feeds.update
|
22
|
+
end
|
23
|
+
|
24
|
+
###
|
25
|
+
# entry
|
26
|
+
#
|
27
|
+
|
28
|
+
class Entry
|
29
|
+
def initialize(title: title, published: published, link: link)
|
30
|
+
@title = title
|
31
|
+
@published = published
|
32
|
+
@link = link
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
###
|
37
|
+
# feed
|
38
|
+
#
|
39
|
+
|
40
|
+
class Feed
|
41
|
+
attr_reader :author
|
42
|
+
attr_reader :url
|
43
|
+
attr_accessor :entries
|
44
|
+
|
45
|
+
def initialize(author)
|
46
|
+
@author = author
|
47
|
+
@feed_url = "https://gdata.youtube.com/feeds/api/users/#{author}/uploads"
|
48
|
+
@entries = []
|
49
|
+
end
|
50
|
+
|
51
|
+
def update
|
52
|
+
update_feed
|
53
|
+
update_info
|
54
|
+
update_entries
|
55
|
+
end
|
56
|
+
|
57
|
+
def update_feed
|
58
|
+
@feed = Nokogiri::HTML(open(@feed_url))
|
59
|
+
end
|
60
|
+
|
61
|
+
def update_info
|
62
|
+
@url = @feed.xpath('id').text
|
63
|
+
@updated = @feed.xpath('updated')
|
64
|
+
end
|
65
|
+
|
66
|
+
def update_entries
|
67
|
+
@feed.xpath("//entry").each do |entry|
|
68
|
+
title = entry.xpath("title").text
|
69
|
+
published = Date.parse(entry.xpath("published").text)
|
70
|
+
link = entry.xpath("link[@rel='alternate']").text
|
71
|
+
|
72
|
+
@entries << Entry.new(title: title, published: published, link: link)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
###
|
78
|
+
# get rid of this?
|
79
|
+
#
|
80
|
+
|
81
|
+
class Feeds
|
82
|
+
attr_accessor :feeds
|
83
|
+
|
84
|
+
def initialize(authors)
|
85
|
+
raise ArgumentError, "authors is not an Array" unless authors.class == Array
|
86
|
+
|
87
|
+
@authors = authors
|
88
|
+
@feeds = []
|
89
|
+
end
|
90
|
+
|
91
|
+
def update
|
92
|
+
populate_feeds
|
93
|
+
update_feeds
|
94
|
+
end
|
95
|
+
|
96
|
+
def populate_feeds
|
97
|
+
@feed = []
|
98
|
+
@authors.each { |author| @feeds << Feed.new(author) }
|
99
|
+
end
|
100
|
+
|
101
|
+
def update_feeds
|
102
|
+
@feeds.each { |feed| feed.update }
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: feedme_youtubes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rob Wilson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: fetch youtube feeds!
|
42
|
+
email:
|
43
|
+
- roobert@gmail.com
|
44
|
+
executables:
|
45
|
+
- feedme
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- bin/feedme
|
54
|
+
- feedme_youtubes.gemspec
|
55
|
+
- lib/feedme_youtubes.rb
|
56
|
+
- lib/feedme_youtubes/version.rb
|
57
|
+
homepage: http://github.com/roobert/feedme_youtubes
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.0.2
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: fetch youtube feeds
|
81
|
+
test_files: []
|