letteropend 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +30 -0
- data/Rakefile +2 -0
- data/examples/compareWatchlist.rb +18 -0
- data/examples/getAllTime.rb +31 -0
- data/examples/getFilmDetails.rb +9 -0
- data/examples/getNumberOfFilms.rb +14 -0
- data/letteropend.gemspec +25 -0
- data/lib/letteropend/film.rb +47 -0
- data/lib/letteropend/list.rb +49 -0
- data/lib/letteropend/version.rb +3 -0
- data/lib/letteropend.rb +3 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d8489fec0a195b80c795eb17a897b2db6845266a
|
4
|
+
data.tar.gz: 7e904e09dbb774f525663ba9176d6f8b7b76af70
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eef68b2dac1d722e39ccdb7d05907c26f60d56e95335b27e6063e11778f22ece6f32f8fb2cb76daf451ffce91dd09bef84b586a1092c804b4620b3d02a5c7d05
|
7
|
+
data.tar.gz: 534f5bfea5d308f9d5d1c6b23c8c1fd0715a2b89b3d4dd12bf5ec4a0a592b4c25e4b8680804e1a7431be95a67dd7fb4afa83430c7d1fa60686eecca1c8d8e08c
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jesse Jurman
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
LetterOpend
|
2
|
+
===========
|
3
|
+
|
4
|
+
Scripts and Functions that let you peek at letterboxd films.
|
5
|
+
|
6
|
+
Sadly, with no API publicly available, this is a quick-hack way of exposing the films that you and your friends have seen, listed, or watchlisted on letterboxd.com
|
7
|
+
|
8
|
+
This is not associated with letterboxd, nor is it guaranteed to work once an official API is released
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'letteropend'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install letteropend
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
|
26
|
+
1. Fork it ( https://github.com/jrjurman/letteropend/fork )
|
27
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
28
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
29
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
30
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative "../lib/letteropend"
|
2
|
+
|
3
|
+
callbacks = {
|
4
|
+
:new_page => lambda{ |list| puts "Getting page {#{list.pages.length}} from #{list.username}'s #{list.list}" }
|
5
|
+
}
|
6
|
+
print "First username: "
|
7
|
+
user1 = gets.chomp
|
8
|
+
|
9
|
+
print "Second username: "
|
10
|
+
user2 = gets.chomp
|
11
|
+
|
12
|
+
user1_wl = Letteropend::List.new(user1, "watchlist", callbacks)
|
13
|
+
user2_wl = Letteropend::List.new(user2, "watchlist", callbacks)
|
14
|
+
|
15
|
+
user2_wl.films.delete_if { |film| !user1_wl.films.include? film }
|
16
|
+
user2_wl.films.each do |film|
|
17
|
+
puts "> #{film.title}"
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative "../lib/letteropend"
|
2
|
+
|
3
|
+
print "Enter username: "
|
4
|
+
un = gets().chomp
|
5
|
+
print "Enter list: "
|
6
|
+
ul = gets().chomp
|
7
|
+
|
8
|
+
# global variable and function ; yeah I know it's jank
|
9
|
+
$ct = 0
|
10
|
+
def pulled_film(film)
|
11
|
+
$ct += film.runtime
|
12
|
+
puts "Adding #{film.runtime} minutes; Total Minutes: #{$ct}"
|
13
|
+
if $ct.to_i < 1440
|
14
|
+
puts "That's #{$ct/60} hours and #{$ct%60} minutes"
|
15
|
+
elsif $ct.to_i < 525600
|
16
|
+
puts "That's #{$ct/1440} days, #{$ct%1440/60} hours, and #{$ct%1440%60} minutes"
|
17
|
+
else
|
18
|
+
puts "That's #{$ct/525600} years, #{$ct%525600/1440} days, #{$ct%545600%1440/60} hours, and #{$ct%535600%1440%60} minutes"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
callbacks = {
|
23
|
+
:new_page => lambda{ |l| puts "pulling data from {#{l.pages.last}}" },
|
24
|
+
:pulling_film => lambda{ |f| puts "pulling data from {#{f.url}}" },
|
25
|
+
:pulled_film => lambda{ |f| Object.send(:pulled_film, f) }
|
26
|
+
}
|
27
|
+
|
28
|
+
l = Letteropend::List.new(un, ul, callbacks)
|
29
|
+
total = l.get_total_time
|
30
|
+
|
31
|
+
puts "Total Runtime: #{total} minutes"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative "../lib/letteropend"
|
2
|
+
|
3
|
+
print "Enter username: "
|
4
|
+
un = gets().chomp
|
5
|
+
print "Enter list: "
|
6
|
+
ul = gets().chomp
|
7
|
+
|
8
|
+
callbacks = {
|
9
|
+
:new_page => lambda{ |l| puts "pulling data from " + l.pages.last},
|
10
|
+
}
|
11
|
+
|
12
|
+
l = Letteropend::List.new(un, ul, callbacks)
|
13
|
+
|
14
|
+
puts "There are #{l.films.length} number of films on #{un}'s #{ul} list"
|
data/letteropend.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'letteropend/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "letteropend"
|
8
|
+
spec.version = Letteropend::VERSION
|
9
|
+
spec.authors = ["Jesse Jurman"]
|
10
|
+
spec.email = ["j.r.jurman@gmail.com"]
|
11
|
+
spec.summary = "exposes films and lists from letterboxd.com"
|
12
|
+
spec.description = "Letteropend is a gem that exposes films and lists stored on letterboxd.com"
|
13
|
+
spec.homepage = "https://github.com/JRJurman/Letteropend"
|
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_dependency "nokogiri", "~> 1.6"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
require "open-uri"
|
3
|
+
|
4
|
+
module Letteropend
|
5
|
+
class Film
|
6
|
+
attr_reader :title, :url, :runtime
|
7
|
+
def initialize(title, url, callbacks={})
|
8
|
+
@title = title
|
9
|
+
@url = url
|
10
|
+
@pulled = false
|
11
|
+
@callbacks = callbacks
|
12
|
+
end
|
13
|
+
|
14
|
+
def runtime
|
15
|
+
if !@pulled
|
16
|
+
pull_data
|
17
|
+
end
|
18
|
+
@runtime
|
19
|
+
end
|
20
|
+
|
21
|
+
def pull_data
|
22
|
+
if @callbacks[:pulling_film]
|
23
|
+
@callbacks[:pulling_film].call(self)
|
24
|
+
end
|
25
|
+
|
26
|
+
# pull the page from the url
|
27
|
+
page = Nokogiri::HTML(open("http://www.letterboxd.com#{@url}"))
|
28
|
+
@pulled = true
|
29
|
+
|
30
|
+
# get the runtime for the film
|
31
|
+
runtime_cap = page.css(".text-link").text.match(/(\d+) mins/)
|
32
|
+
if runtime_cap
|
33
|
+
@runtime = runtime_cap.captures[0].to_i
|
34
|
+
else
|
35
|
+
@runtime = 0
|
36
|
+
end
|
37
|
+
|
38
|
+
if @callbacks[:pulled_film]
|
39
|
+
@callbacks[:pulled_film].call(self)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def ==(film)
|
44
|
+
@title == film.title and @url == film.url
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
require_relative './Film'
|
4
|
+
|
5
|
+
module Letteropend
|
6
|
+
class List
|
7
|
+
attr_reader :username, :list, :films, :pages
|
8
|
+
|
9
|
+
def initialize(username, list="films", callbacks={})
|
10
|
+
@username = username
|
11
|
+
@list = list
|
12
|
+
|
13
|
+
@films = []
|
14
|
+
@pages = ["/#{username}/#{list}/page/1/"]
|
15
|
+
begin
|
16
|
+
# get page using Nokogiri
|
17
|
+
if callbacks[:new_page]
|
18
|
+
callbacks[:new_page].call(self)
|
19
|
+
end
|
20
|
+
page = Nokogiri::HTML(open("http://www.letterboxd.com#{@pages.last}"))
|
21
|
+
|
22
|
+
# append visible films to @films
|
23
|
+
page.css(".poster").each do |film|
|
24
|
+
title = film.css(".frame-title").text
|
25
|
+
url = film.css("a")[0].attr("href")
|
26
|
+
@films.push( Film.new(title, url, callbacks) )
|
27
|
+
if callbacks[:new_film]
|
28
|
+
callbacks[:new_film].call(self)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# see if there is a next page
|
33
|
+
next_page = page.css('a.paginate-next')[0]
|
34
|
+
if ( next_page )
|
35
|
+
@pages.push( next_page.attr("href") )
|
36
|
+
end
|
37
|
+
end while ( next_page )
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_total_time
|
41
|
+
total_runtime = 0
|
42
|
+
@films.each do |film|
|
43
|
+
total_runtime += film.runtime
|
44
|
+
end
|
45
|
+
return total_runtime
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
data/lib/letteropend.rb
ADDED
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: letteropend
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jesse Jurman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Letteropend is a gem that exposes films and lists stored on letterboxd.com
|
56
|
+
email:
|
57
|
+
- j.r.jurman@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- Gemfile
|
63
|
+
- LICENSE.txt
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- examples/compareWatchlist.rb
|
67
|
+
- examples/getAllTime.rb
|
68
|
+
- examples/getFilmDetails.rb
|
69
|
+
- examples/getNumberOfFilms.rb
|
70
|
+
- letteropend.gemspec
|
71
|
+
- lib/letteropend.rb
|
72
|
+
- lib/letteropend/film.rb
|
73
|
+
- lib/letteropend/list.rb
|
74
|
+
- lib/letteropend/version.rb
|
75
|
+
homepage: https://github.com/JRJurman/Letteropend
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.4.1
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: exposes films and lists from letterboxd.com
|
99
|
+
test_files: []
|