{"action":"created","comment":{"url":"https://api.github.com/repos/bf4/downloader/pulls/comments/32530831","id":32530831,"diff_hunk":"@@ -0,0 +1,89 @@\n+require 'fileutils'\n+require 'pathname'\n+require_relative 'downloader/config'\n+require_relative 'downloader/scraper'\n+\n+class PinboardTabsDownloader\n+\n+  attr_reader :scraper, :all_episodes\n+  def initialize\n+    @lib_root     = File.expand_path(File.join(File.dirname(__FILE__),'..'))\n+    @download_dir = File.join(lib_root, 'pinboard_tabs')\n+    @temp_dir     = File.join(lib_root, 'tmp')\n+    FileUtils.mkdir_p @download_dir\n+    FileUtils.mkdir_p @temp_dir\n+    STDOUT.sync = true\n+    set_credentials\n+    @scraper = RubyTapasDownloader::HtmlScraper.new(@username, @password)\n+    log \"initialized\"\n+  end\n+\n+  def pinboard_url\n+    \"https://pinboard.in/\"\n+  end\n+  def tabs_url\n+    @tabs_url ||= \"u:#{@username}/tabs/\"\n+  end\n+\n+  def sign_in_url\n+    pinboard_url\n+  end\n+\n+  def get_tabs\n+    @scraper.sign_in(sign_in_url)\n+    tabs_page = @scraper.get(pinboard_url + tabs_url)\n+    @tabs_pages ||= tabs_page.search(\"#main_column td a\").map {|a|\n+      [a.attribute('href').to_s, a.text]\n+    }.reject {|href, text|\n+      !href.include?(tabs_url)\n+    }\n+    self\n+  end\n+\n+  def download\n+    @tabs_pages.each do |href, text|\n+      puts \"Downloading #{href}: #{text}\"\n+      tab_number = href.split('/')[-1]","path":"lib/pinboard_tabs_downloader.rb","position":46,"original_position":46,"commit_id":"fd921898df872a1963883cd3e1c098c6a12db62a","original_commit_id":"fd921898df872a1963883cd3e1c098c6a12db62a","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.","created_at":"2015-06-16T15:09:59Z","updated_at":"2015-06-16T15:09:59Z","html_url":"https://github.com/bf4/downloader/pull/2#discussion_r32530831","pull_request_url":"https://api.github.com/repos/bf4/downloader/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/bf4/downloader/pulls/comments/32530831"},"html":{"href":"https://github.com/bf4/downloader/pull/2#discussion_r32530831"},"pull_request":{"href":"https://api.github.com/repos/bf4/downloader/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/bf4/downloader/pulls/2","id":35442931,"html_url":"https://github.com/bf4/downloader/pull/2","diff_url":"https://github.com/bf4/downloader/pull/2.diff","patch_url":"https://github.com/bf4/downloader/pull/2.patch","issue_url":"https://api.github.com/repos/bf4/downloader/issues/2","number":2,"state":"open","locked":false,"title":"Pinboard tabs link downloader","user":{"login":"bf4","id":142914,"avatar_url":"https://avatars.githubusercontent.com/u/142914?v=3","gravatar_id":"","url":"https://api.github.com/users/bf4","html_url":"https://github.com/bf4","followers_url":"https://api.github.com/users/bf4/followers","following_url":"https://api.github.com/users/bf4/following{/other_user}","gists_url":"https://api.github.com/users/bf4/gists{/gist_id}","starred_url":"https://api.github.com/users/bf4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bf4/subscriptions","organizations_url":"https://api.github.com/users/bf4/orgs","repos_url":"https://api.github.com/users/bf4/repos","events_url":"https://api.github.com/users/bf4/events{/privacy}","received_events_url":"https://api.github.com/users/bf4/received_events","type":"User","site_admin":false},"body":null,"created_at":"2015-05-14T17:33:36Z","updated_at":"2015-06-16T15:09:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"29f01461924ad32d800734fd6b75d186b24d2963","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bf4/downloader/pulls/2/commits","review_comments_url":"https://api.github.com/repos/bf4/downloader/pulls/2/comments","review_comment_url":"https://api.github.com/repos/bf4/downloader/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bf4/downloader/issues/2/comments","statuses_url":"https://api.github.com/repos/bf4/downloader/statuses/fd921898df872a1963883cd3e1c098c6a12db62a","head":{"label":"bf4:pinboard","ref":"pinboard","sha":"fd921898df872a1963883cd3e1c098c6a12db62a","user":{"login":"bf4","id":142914,"avatar_url":"https://avatars.githubusercontent.com/u/142914?v=3","gravatar_id":"","url":"https://api.github.com/users/bf4","html_url":"https://github.com/bf4","followers_url":"https://api.github.com/users/bf4/followers","following_url":"https://api.github.com/users/bf4/following{/other_user}","gists_url":"https://api.github.com/users/bf4/gists{/gist_id}","starred_url":"https://api.github.com/users/bf4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bf4/subscriptions","organizations_url":"https://api.github.com/users/bf4/orgs","repos_url":"https://api.github.com/users/bf4/repos","events_url":"https://api.github.com/users/bf4/events{/privacy}","received_events_url":"https://api.github.com/users/bf4/received_events","type":"User","site_admin":false},"repo":{"id":12716602,"name":"downloader","full_name":"bf4/downloader","owner":{"login":"bf4","id":142914,"avatar_url":"https://avatars.githubusercontent.com/u/142914?v=3","gravatar_id":"","url":"https://api.github.com/users/bf4","html_url":"https://github.com/bf4","followers_url":"https://api.github.com/users/bf4/followers","following_url":"https://api.github.com/users/bf4/following{/other_user}","gists_url":"https://api.github.com/users/bf4/gists{/gist_id}","starred_url":"https://api.github.com/users/bf4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bf4/subscriptions","organizations_url":"https://api.github.com/users/bf4/orgs","repos_url":"https://api.github.com/users/bf4/repos","events_url":"https://api.github.com/users/bf4/events{/privacy}","received_events_url":"https://api.github.com/users/bf4/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bf4/downloader","description":"RubyTapas downloader, maybe more","fork":false,"url":"https://api.github.com/repos/bf4/downloader","forks_url":"https://api.github.com/repos/bf4/downloader/forks","keys_url":"https://api.github.com/repos/bf4/downloader/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bf4/downloader/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bf4/downloader/teams","hooks_url":"https://api.github.com/repos/bf4/downloader/hooks","issue_events_url":"https://api.github.com/repos/bf4/downloader/issues/events{/number}","events_url":"https://api.github.com/repos/bf4/downloader/events","assignees_url":"https://api.github.com/repos/bf4/downloader/assignees{/user}","branches_url":"https://api.github.com/repos/bf4/downloader/branches{/branch}","tags_url":"https://api.github.com/repos/bf4/downloader/tags","blobs_url":"https://api.github.com/repos/bf4/downloader/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bf4/downloader/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bf4/downloader/git/refs{/sha}","trees_url":"https://api.github.com/repos/bf4/downloader/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bf4/downloader/statuses/{sha}","languages_url":"https://api.github.com/repos/bf4/downloader/languages","stargazers_url":"https://api.github.com/repos/bf4/downloader/stargazers","contributors_url":"https://api.github.com/repos/bf4/downloader/contributors","subscribers_url":"https://api.github.com/repos/bf4/downloader/subscribers","subscription_url":"https://api.github.com/repos/bf4/downloader/subscription","commits_url":"https://api.github.com/repos/bf4/downloader/commits{/sha}","git_commits_url":"https://api.github.com/repos/bf4/downloader/git/commits{/sha}","comments_url":"https://api.github.com/repos/bf4/downloader/comments{/number}","issue_comment_url":"https://api.github.com/repos/bf4/downloader/issues/comments{/number}","contents_url":"https://api.github.com/repos/bf4/downloader/contents/{+path}","compare_url":"https://api.github.com/repos/bf4/downloader/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bf4/downloader/merges","archive_url":"https://api.github.com/repos/bf4/downloader/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bf4/downloader/downloads","issues_url":"https://api.github.com/repos/bf4/downloader/issues{/number}","pulls_url":"https://api.github.com/repos/bf4/downloader/pulls{/number}","milestones_url":"https://api.github.com/repos/bf4/downloader/milestones{/number}","notifications_url":"https://api.github.com/repos/bf4/downloader/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bf4/downloader/labels{/name}","releases_url":"https://api.github.com/repos/bf4/downloader/releases{/id}","created_at":"2013-09-10T00:51:13Z","updated_at":"2015-02-07T03:56:43Z","pushed_at":"2015-06-16T15:09:51Z","git_url":"git://github.com/bf4/downloader.git","ssh_url":"git@github.com:bf4/downloader.git","clone_url":"https://github.com/bf4/downloader.git","svn_url":"https://github.com/bf4/downloader","homepage":null,"size":243,"stargazers_count":7,"watchers_count":7,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":7,"default_branch":"master"}},"base":{"label":"bf4:master","ref":"master","sha":"5d64cd9f808130c2d05a19f8388dbeded34b9686","user":{"login":"bf4","id":142914,"avatar_url":"https://avatars.githubusercontent.com/u/142914?v=3","gravatar_id":"","url":"https://api.github.com/users/bf4","html_url":"https://github.com/bf4","followers_url":"https://api.github.com/users/bf4/followers","following_url":"https://api.github.com/users/bf4/following{/other_user}","gists_url":"https://api.github.com/users/bf4/gists{/gist_id}","starred_url":"https://api.github.com/users/bf4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bf4/subscriptions","organizations_url":"https://api.github.com/users/bf4/orgs","repos_url":"https://api.github.com/users/bf4/repos","events_url":"https://api.github.com/users/bf4/events{/privacy}","received_events_url":"https://api.github.com/users/bf4/received_events","type":"User","site_admin":false},"repo":{"id":12716602,"name":"downloader","full_name":"bf4/downloader","owner":{"login":"bf4","id":142914,"avatar_url":"https://avatars.githubusercontent.com/u/142914?v=3","gravatar_id":"","url":"https://api.github.com/users/bf4","html_url":"https://github.com/bf4","followers_url":"https://api.github.com/users/bf4/followers","following_url":"https://api.github.com/users/bf4/following{/other_user}","gists_url":"https://api.github.com/users/bf4/gists{/gist_id}","starred_url":"https://api.github.com/users/bf4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bf4/subscriptions","organizations_url":"https://api.github.com/users/bf4/orgs","repos_url":"https://api.github.com/users/bf4/repos","events_url":"https://api.github.com/users/bf4/events{/privacy}","received_events_url":"https://api.github.com/users/bf4/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bf4/downloader","description":"RubyTapas downloader, maybe more","fork":false,"url":"https://api.github.com/repos/bf4/downloader","forks_url":"https://api.github.com/repos/bf4/downloader/forks","keys_url":"https://api.github.com/repos/bf4/downloader/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bf4/downloader/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bf4/downloader/teams","hooks_url":"https://api.github.com/repos/bf4/downloader/hooks","issue_events_url":"https://api.github.com/repos/bf4/downloader/issues/events{/number}","events_url":"https://api.github.com/repos/bf4/downloader/events","assignees_url":"https://api.github.com/repos/bf4/downloader/assignees{/user}","branches_url":"https://api.github.com/repos/bf4/downloader/branches{/branch}","tags_url":"https://api.github.com/repos/bf4/downloader/tags","blobs_url":"https://api.github.com/repos/bf4/downloader/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bf4/downloader/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bf4/downloader/git/refs{/sha}","trees_url":"https://api.github.com/repos/bf4/downloader/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bf4/downloader/statuses/{sha}","languages_url":"https://api.github.com/repos/bf4/downloader/languages","stargazers_url":"https://api.github.com/repos/bf4/downloader/stargazers","contributors_url":"https://api.github.com/repos/bf4/downloader/contributors","subscribers_url":"https://api.github.com/repos/bf4/downloader/subscribers","subscription_url":"https://api.github.com/repos/bf4/downloader/subscription","commits_url":"https://api.github.com/repos/bf4/downloader/commits{/sha}","git_commits_url":"https://api.github.com/repos/bf4/downloader/git/commits{/sha}","comments_url":"https://api.github.com/repos/bf4/downloader/comments{/number}","issue_comment_url":"https://api.github.com/repos/bf4/downloader/issues/comments{/number}","contents_url":"https://api.github.com/repos/bf4/downloader/contents/{+path}","compare_url":"https://api.github.com/repos/bf4/downloader/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bf4/downloader/merges","archive_url":"https://api.github.com/repos/bf4/downloader/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bf4/downloader/downloads","issues_url":"https://api.github.com/repos/bf4/downloader/issues{/number}","pulls_url":"https://api.github.com/repos/bf4/downloader/pulls{/number}","milestones_url":"https://api.github.com/repos/bf4/downloader/milestones{/number}","notifications_url":"https://api.github.com/repos/bf4/downloader/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bf4/downloader/labels{/name}","releases_url":"https://api.github.com/repos/bf4/downloader/releases{/id}","created_at":"2013-09-10T00:51:13Z","updated_at":"2015-02-07T03:56:43Z","pushed_at":"2015-06-16T15:09:51Z","git_url":"git://github.com/bf4/downloader.git","ssh_url":"git@github.com:bf4/downloader.git","clone_url":"https://github.com/bf4/downloader.git","svn_url":"https://github.com/bf4/downloader","homepage":null,"size":243,"stargazers_count":7,"watchers_count":7,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bf4/downloader/pulls/2"},"html":{"href":"https://github.com/bf4/downloader/pull/2"},"issue":{"href":"https://api.github.com/repos/bf4/downloader/issues/2"},"comments":{"href":"https://api.github.com/repos/bf4/downloader/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/bf4/downloader/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/bf4/downloader/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bf4/downloader/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/bf4/downloader/statuses/fd921898df872a1963883cd3e1c098c6a12db62a"}}}}