simple-fourchan 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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +114 -0
- data/Rakefile +2 -0
- data/lib/simple-fourchan.rb +28 -0
- data/lib/simple-fourchan/version.rb +5 -0
- data/simple-fourchan.gemspec +19 -0
- metadata +61 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Chim Kan
|
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,114 @@
|
|
1
|
+
# 4chan
|
2
|
+
|
3
|
+
4chan is a gem that fetches posts from 4chan. Current version only fetches a specific listing now and it works only for READ. There's the 4chan.js that posts but the documentation is not clear yet. Index will come once it 4chan releases it or you discover how to fetch it though json.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Just do in your Gemfile or install and do require '4chan'.
|
8
|
+
|
9
|
+
gem 'simple-fourchan'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install simple-fourchan
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
For now, you can only fetch a reply list to a subject.
|
22
|
+
|
23
|
+
array = Fourchan::Post.new "w", "1403853"
|
24
|
+
|
25
|
+
Example:
|
26
|
+
|
27
|
+
If the gem is loaded:
|
28
|
+
|
29
|
+
array = Fourchan::Post.new "w", "1403853"
|
30
|
+
|
31
|
+
It returns an array of 4chan posts.
|
32
|
+
|
33
|
+
You should start like this:
|
34
|
+
|
35
|
+
array = Fourchan::Post.new "w", "1403853"
|
36
|
+
posts = array.all
|
37
|
+
|
38
|
+
Useful methods:
|
39
|
+
|
40
|
+
Some methods may be missed depending what user submitted: title, image, thumb, etc....
|
41
|
+
|
42
|
+
posts.each do |post|
|
43
|
+
post.title # => "One of the best anime's in my opinion!"
|
44
|
+
post.now # => "09\/06\/12(Thu)14:20"
|
45
|
+
post.name # => "Anonymous"
|
46
|
+
post.email # => "random@email.com"
|
47
|
+
post.com # => "One of the best anime's in my opinion!"
|
48
|
+
post.image # => "http://images.4chan.org/w/src/1346955606165.jpg"
|
49
|
+
post.thumb # => "http://thumbs.4chan.org/w/thumb/1346955606165s.jpg"
|
50
|
+
post.link # => "http://boards.4chan.org/w/res/1403853"
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
You can also do this in a more through way:
|
55
|
+
|
56
|
+
posts.each do |post|
|
57
|
+
|
58
|
+
puts post.no
|
59
|
+
# 1403714
|
60
|
+
puts post.sticky
|
61
|
+
# 0
|
62
|
+
puts post.closed
|
63
|
+
# 0
|
64
|
+
puts post.now
|
65
|
+
# "09\/06\/12(Thu)14:20"
|
66
|
+
puts post.name
|
67
|
+
# "Anonymous"
|
68
|
+
puts post.email
|
69
|
+
# ""
|
70
|
+
puts post.sub
|
71
|
+
# ""
|
72
|
+
puts post.com
|
73
|
+
# "One of the best anime's in my opinion!"
|
74
|
+
puts post.filename
|
75
|
+
# "yoshimori and tokine wallpaper"
|
76
|
+
puts post.ext
|
77
|
+
# ".jpg"
|
78
|
+
puts post.w
|
79
|
+
# 1024
|
80
|
+
puts post.h
|
81
|
+
# 693
|
82
|
+
puts post.tn_w
|
83
|
+
# 250
|
84
|
+
puts post.tn_h
|
85
|
+
#169
|
86
|
+
puts post.tim
|
87
|
+
# 1346955606165
|
88
|
+
puts post.time
|
89
|
+
# 1346955606
|
90
|
+
puts post.md5
|
91
|
+
# "Rw+TXj1fkCTDKmj2DP2SfQ=="
|
92
|
+
puts post.fsize
|
93
|
+
# 257664
|
94
|
+
puts post.resto
|
95
|
+
# 0
|
96
|
+
puts post.trip
|
97
|
+
# ""
|
98
|
+
# Check the end of this file to see the json example from 4chan.
|
99
|
+
end
|
100
|
+
|
101
|
+
For now, you should be able to access the content in the following way:
|
102
|
+
|
103
|
+
|
104
|
+
Json example from 4chan.
|
105
|
+
|
106
|
+
{"posts": [{"no":1403714,"sticky":0,"closed":0,"now":"09\/06\/12(Thu)14:20","name":"Anonymous","email":"","sub":"","com":"One of the best anime's in my opinion!","filename":"yoshimori and tokine wallpaper","ext":".jpg","w":1024,"h":693,"tn_w":250,"tn_h":169,"tim":1346955606165,"time":1346955606,"md5":"Rw+TXj1fkCTDKmj2DP2SfQ==","fsize":257664,"resto":0,"trip":""},{"no":1403717,"now":"09\/06\/12(Thu)14:25","name":"Lol","email":"","sub":"","com":"You don't know anime","time":1346955928,"resto":1403714,"trip":""},{"no":1403728,"now":"09\/06\/12(Thu)14:41","name":"Anonymous","email":"","sub":"","com":"<span class=\"quote\"><a href=\"1403714#p1403717\" class=\"quotelink\">>>1403717<\/a><\/span><br>Lol I do. Plus it's an opinion :P","time":1346956912,"resto":1403714,"trip":""},{"no":1403786,"now":"09\/06\/12(Thu)16:43","name":"Anonymous","email":"","sub":"","com":"I see you didn't watch Boku no Pico.","time":1346964202,"resto":1403714,"trip":""}]}
|
107
|
+
|
108
|
+
## Contributing
|
109
|
+
|
110
|
+
1. Fork it
|
111
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
112
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
113
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
114
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "simple-fourchan/version"
|
2
|
+
require "open-uri"
|
3
|
+
require "json"
|
4
|
+
require "ostruct"
|
5
|
+
|
6
|
+
module Fourchan
|
7
|
+
class Post
|
8
|
+
def initialize( board, thread)
|
9
|
+
@board = board
|
10
|
+
@thread = thread.to_i
|
11
|
+
@posts = []
|
12
|
+
temp = JSON.parse(open("http://api.4chan.org/#{@board}/res/#{@thread}.json").read)["posts"]
|
13
|
+
temp.each do |post|
|
14
|
+
tim = post["tim"]
|
15
|
+
post.merge!({"image" => "http://images.4chan.org/#{@board}/src/#{tim}.jpg"}) unless tim.nil?
|
16
|
+
post.merge!({"thumb" => "http://thumbs.4chan.org/#{@board}/thumb/#{tim}s.jpg"}) unless tim.nil?
|
17
|
+
post.merge!({"link" => "http://boards.4chan.org/#{@board}/res/#{@thread}"})
|
18
|
+
@posts << OpenStruct.new(post)
|
19
|
+
end
|
20
|
+
@posts
|
21
|
+
end
|
22
|
+
|
23
|
+
def all
|
24
|
+
@posts
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/simple-fourchan/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Chim Kan"]
|
6
|
+
gem.email = ["designium@gmail.com"]
|
7
|
+
gem.description = "4chan is a gem that fetches posts from 4chan. Current version only fetches a specific listing now and it works only for READ. There's the 4chan.js that posts but the documentation is not clear yet. Index will come once it 4chan releases it or you discover how to fetch it though json."
|
8
|
+
gem.summary = "4chan is a gem that fetches posts from 4chan. Current version only fetches a specific listing now and it works only for READ. There's the 4chan.js that posts but the documentation is not clear yet. Index will come once it 4chan releases it or you discover how to fetch it though json."
|
9
|
+
gem.homepage = "http://4chan.org"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "simple-fourchan"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Simple::Fourchan::VERSION
|
17
|
+
gem.post_install_message = "***************************************\n Thanks for using 4chan gem \n \n LOL \n U belongs to us now. \n***************************************\n"
|
18
|
+
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simple-fourchan
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chim Kan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-07 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: 4chan is a gem that fetches posts from 4chan. Current version only fetches
|
15
|
+
a specific listing now and it works only for READ. There's the 4chan.js that posts
|
16
|
+
but the documentation is not clear yet. Index will come once it 4chan releases it
|
17
|
+
or you discover how to fetch it though json.
|
18
|
+
email:
|
19
|
+
- designium@gmail.com
|
20
|
+
executables: []
|
21
|
+
extensions: []
|
22
|
+
extra_rdoc_files: []
|
23
|
+
files:
|
24
|
+
- .gitignore
|
25
|
+
- Gemfile
|
26
|
+
- LICENSE
|
27
|
+
- README.md
|
28
|
+
- Rakefile
|
29
|
+
- lib/simple-fourchan.rb
|
30
|
+
- lib/simple-fourchan/version.rb
|
31
|
+
- simple-fourchan.gemspec
|
32
|
+
homepage: http://4chan.org
|
33
|
+
licenses: []
|
34
|
+
post_install_message: ! "***************************************\n Thanks for
|
35
|
+
using 4chan gem \n \n LOL
|
36
|
+
\ \n U belongs to us now. \n***************************************\n"
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.8.24
|
55
|
+
signing_key:
|
56
|
+
specification_version: 3
|
57
|
+
summary: 4chan is a gem that fetches posts from 4chan. Current version only fetches
|
58
|
+
a specific listing now and it works only for READ. There's the 4chan.js that posts
|
59
|
+
but the documentation is not clear yet. Index will come once it 4chan releases it
|
60
|
+
or you discover how to fetch it though json.
|
61
|
+
test_files: []
|