overcast-time 1.0.0
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/bin/overcast-time +4 -0
- data/lib/overcast-time.rb +63 -0
- metadata +46 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: dd163420d8444515171cec87806541c1660611c0
|
|
4
|
+
data.tar.gz: 6f814c03e730b00eaeaecce4c17bd3640b220004
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 06b34f7db89dd5ccd0558798acee734ce9fb93f6dcc90bdac0fa2e9d32968289802b578c824a826b50486f150c244915089a20567c6fad4482d80c182bfb16f6
|
|
7
|
+
data.tar.gz: 9f765a6f2499c14fa22bc1f8be0015c78ec215fc5ca0c7ba014ac69109f4391209fc61aa4889d4fca7c52f81b923dee89bd7c71b5534c2c8c4cec2d6649cb0fb
|
data/bin/overcast-time
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'mechanize'
|
|
3
|
+
require 'figaro'
|
|
4
|
+
require 'nokogiri'
|
|
5
|
+
require 'io/console'
|
|
6
|
+
|
|
7
|
+
class OvercastTime
|
|
8
|
+
|
|
9
|
+
def initialize
|
|
10
|
+
puts "Please enter your Overcast.fm username (your email address)."
|
|
11
|
+
email = gets.chomp
|
|
12
|
+
print "Please enter your Overcast.fm password: "
|
|
13
|
+
password = STDIN.noecho(&:gets).chomp
|
|
14
|
+
fname = "lib/application.yml"
|
|
15
|
+
secrets = File.open(fname, "w")
|
|
16
|
+
secrets.puts("overcast_user_name: " + email)
|
|
17
|
+
secrets.puts("overcast_password: " + password)
|
|
18
|
+
secrets.close
|
|
19
|
+
Figaro.application = Figaro::Application.new(environment: "production", path: "lib/application.yml")
|
|
20
|
+
Figaro.load
|
|
21
|
+
|
|
22
|
+
agent = Mechanize.new
|
|
23
|
+
|
|
24
|
+
page = agent.get("http://overcast.fm")
|
|
25
|
+
|
|
26
|
+
login_page = agent.page.link_with(:text => 'Log In').click
|
|
27
|
+
|
|
28
|
+
login_form = login_page.forms[0]
|
|
29
|
+
|
|
30
|
+
puts ENV['overcast_user_name']
|
|
31
|
+
|
|
32
|
+
login_form.email = ENV['overcast_user_name']
|
|
33
|
+
login_form.password = ENV['overcast_password']
|
|
34
|
+
|
|
35
|
+
podcasts = agent.submit(login_form, login_form.buttons[2])
|
|
36
|
+
|
|
37
|
+
times = podcasts.search('div.caption2')
|
|
38
|
+
|
|
39
|
+
total_seconds = 0
|
|
40
|
+
|
|
41
|
+
times.each do |time|
|
|
42
|
+
timestamp = time.text.match(/([0-9]+:)([0-9]+:)([0-9]+)/)
|
|
43
|
+
if timestamp
|
|
44
|
+
hours = timestamp[1][0...-1].to_i
|
|
45
|
+
total_seconds += hours * 3600
|
|
46
|
+
minutes = timestamp[2][0...-1].to_i
|
|
47
|
+
total_seconds += minutes * 60
|
|
48
|
+
seconds = timestamp[3].to_i
|
|
49
|
+
total_seconds += seconds
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
mm, ss = total_seconds.divmod(60)
|
|
54
|
+
hh, mm = mm.divmod(60)
|
|
55
|
+
|
|
56
|
+
puts "You have %d hours, %d minutes, and %d seconds of unheard podcasts remaining." % [hh, mm, ss]
|
|
57
|
+
|
|
58
|
+
File.delete("lib/application.yml")
|
|
59
|
+
|
|
60
|
+
return total_seconds
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: overcast-time
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Nabil Hashmi
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-05-26 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description:
|
|
14
|
+
email: nabil2011@gmail.com
|
|
15
|
+
executables:
|
|
16
|
+
- overcast-time
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- bin/overcast-time
|
|
21
|
+
- lib/overcast-time.rb
|
|
22
|
+
homepage: https://github.com/nhashmi/overcast-time
|
|
23
|
+
licenses:
|
|
24
|
+
- MIT
|
|
25
|
+
metadata: {}
|
|
26
|
+
post_install_message:
|
|
27
|
+
rdoc_options: []
|
|
28
|
+
require_paths:
|
|
29
|
+
- lib
|
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '0'
|
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
requirements: []
|
|
41
|
+
rubyforge_project:
|
|
42
|
+
rubygems_version: 2.4.6
|
|
43
|
+
signing_key:
|
|
44
|
+
specification_version: 4
|
|
45
|
+
summary: Calculate the time remaining on your Overcast.fm podcasts.
|
|
46
|
+
test_files: []
|