Last active
December 24, 2015 09:59
-
-
Save gong023/6781036 to your computer and use it in GitHub Desktop.
fix nicnonico login
fix ranking parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/niconico.rb b/lib/niconico.rb | |
index da773f9..d9f8940 100644 | |
--- a/lib/niconico.rb | |
+++ b/lib/niconico.rb | |
@@ -22,6 +22,7 @@ class Niconico | |
@logined = false | |
@agent = Mechanize.new | |
+ @agent.ssl_version = "SSLv3" | |
end | |
def login(force=false) | |
diff --git a/lib/niconico/ranking.rb b/lib/niconico/ranking.rb | |
index 25c83e1..1a1ee6d 100644 | |
--- a/lib/niconico/ranking.rb | |
+++ b/lib/niconico/ranking.rb | |
@@ -22,8 +22,13 @@ class Niconico | |
method = :fav if method == :all | |
page = @agent.get(url = "http://www.nicovideo.jp/ranking/#{method}/#{span}/#{category}") | |
- page.search("a.watch").map do |link| | |
- Video.new(self, link['href'].sub(/^.*?watch\//,""), title: link.inner_text) | |
+ kuso_arr = [] | |
+ page.search("p.itemTitle.ranking").each do |link| | |
+ link.children.search("a").each do |elem| | |
+ matches = elem.attributes["href"].value.match(/(?<category>^.*?watch\/)(?<video_id>[a-z]+\d+)/) | |
+ kuso_arr << Video.new(self, matches["video_id"], title: elem.attributes["title"].value) | |
+ end | |
end | |
+ kuso_arr | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment