{"action":"created","comment":{"url":"https://api.github.com/repos/dmitrydi/movie_pack/pulls/comments/73879322","id":73879322,"diff_hunk":"@@ -0,0 +1,57 @@\n+\r\n+module MovieData\r\n+  module TMDBData\r\n+  # module for fetching data using TMDB API\r\n+    def self.make_id_list(top_chart_url, file_name = DEFAULT_ID_FILE)\r\n+      main_page = Nokogiri.HTML(WebHelper.cached_get(top_chart_url), nil, 'UTF-8')\r\n+\r\n+      id_list =\r\n+        main_page\r\n+        .css('td.titleColumn a')\r\n+        .map do |blok|\r\n+          imdb_id = MovieData.fetch_id_from(blok['href'])\r\n+          movie = Tmdb::Find.movie(imdb_id, external_source: 'imdb_id').first\r\n+          { id: movie.id, imdb_id: imdb_id, name: blok.text }\r\n+        end\r\n+        .to_yaml\r\n+    \r\n+      FileUtils.mkdir_p DATA_PATH\r\n+      File.write(file_name, id_list)\r\n+    end\r\n+\r\n+    def self.check_id_list(id_list, top_chart_url)\r\n+      make_id_list(top_chart_url, id_list) unless File.file?(id_list)\r\n+    end\r\n+\r\n+\r\n+    def self.fetch_posters(dir, id_list = DEFAULT_ID_FILE, top_chart_url = TOP_250_URL)\r\n+      check_id_list(id_list, top_chart_url)\r\n+      contents = YAML.load_file(id_list)\r\n+      FileUtils.mkdir_p dir\r\n+\r\n+      contents.each do |data|\r\n+        id = data[:id]\r\n+        fname = File.join(dir, id.to_s + '.jpg')\r\n+        unless File.file?(fname)\r\n+          poster_url = BASE_IMAGE_URL + Tmdb::Movie.detail(id).poster_path\r\n+          File.open(fname, 'wb') { |f| f.write open(poster_url).read }\r\n+        end\r\n+      end\r\n+    end\r\n+\r\n+    def self.fetch_alt_titles(file_name, id_list = DEFAULT_ID_FILE, top_chart_url = TOP_250_URL)\r\n+      check_id_list(id_list, top_chart_url)\r\n+      contents = YAML.load_file(id_list)\r\n+      alt_titles = \r\n+        contents.map do |data|\r\n+          id = data[:id]\r\n+          titles = Tmdb::Movie.alternative_titles(id).map { |t| t.title }\r\n+          { id: id, imdb_id: data[:imdb_id], titles: titles }\r\n+        end\r\n+        .to_yaml\r\n+\r\n+      FileUtils.mkdir_p DATA_PATH\r\n+      File.write(file_name, alt_titles)\r\n+    end\r\n+  end\r","path":"lib/movie_data/tmdb_data.rb","position":56,"original_position":56,"commit_id":"a3fd72a54e150e1f75b073f27a1d4fd2b093e547","original_commit_id":"a3fd72a54e150e1f75b073f27a1d4fd2b093e547","user":{"login":"dmitrydi","id":19414894,"avatar_url":"https://avatars.githubusercontent.com/u/19414894?v=3","gravatar_id":"","url":"https://api.github.com/users/dmitrydi","html_url":"https://github.com/dmitrydi","followers_url":"https://api.github.com/users/dmitrydi/followers","following_url":"https://api.github.com/users/dmitrydi/following{/other_user}","gists_url":"https://api.github.com/users/dmitrydi/gists{/gist_id}","starred_url":"https://api.github.com/users/dmitrydi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmitrydi/subscriptions","organizations_url":"https://api.github.com/users/dmitrydi/orgs","repos_url":"https://api.github.com/users/dmitrydi/repos","events_url":"https://api.github.com/users/dmitrydi/events{/privacy}","received_events_url":"https://api.github.com/users/dmitrydi/received_events","type":"User","site_admin":false},"body":"Я тебя правильно понял?\r\n```ruby\r\n    class TMDBFetcher\r\n      def initialize(\r\n        id_file: DEFAULT_ID_FILE,\r\n        posters_path: POSTERS_PATH,\r\n        alt_titles_file: ALT_TITLES_FILE\r\n      )\r\n        TMDBData.set_api_key\r\n        @missing_posters_ids = check_missing_posters(id_file, posters_path)\r\n        @missing_alt_titles_ids = check_missing_alt_titles(id_file, alt_titles_file)\r\n\r\n      end\r\n\r\n      attr_reader :missing_posters_ids, :missing_alt_titles_ids\r\n\r\n      def self.fetch_posters\r\n        @missing_posters_ids.each do |id|\r\n          fname = File.join(@posters_dir, id.to_s + '.jpg')\r\n          poster_url = BASE_IMAGE_URL + Tmdb::Movie.detail(id).poster_path\r\n          File.open(fname, 'wb') { |f| f.write open(poster_url).read }\r\n        end\r\n      end\r\n    end\r\n```","created_at":"2016-08-08T13:59:04Z","updated_at":"2016-08-08T13:59:04Z","html_url":"https://github.com/dmitrydi/movie_pack/pull/7#discussion_r73879322","pull_request_url":"https://api.github.com/repos/dmitrydi/movie_pack/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/dmitrydi/movie_pack/pulls/comments/73879322"},"html":{"href":"https://github.com/dmitrydi/movie_pack/pull/7#discussion_r73879322"},"pull_request":{"href":"https://api.github.com/repos/dmitrydi/movie_pack/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/dmitrydi/movie_pack/pulls/7","id":79328002,"html_url":"https://github.com/dmitrydi/movie_pack/pull/7","diff_url":"https://github.com/dmitrydi/movie_pack/pull/7.diff","patch_url":"https://github.com/dmitrydi/movie_pack/pull/7.patch","issue_url":"https://api.github.com/repos/dmitrydi/movie_pack/issues/7","number":7,"state":"open","locked":false,"title":"Task 10 diff","user":{"login":"dmitrydi","id":19414894,"avatar_url":"https://avatars.githubusercontent.com/u/19414894?v=3","gravatar_id":"","url":"https://api.github.com/users/dmitrydi","html_url":"https://github.com/dmitrydi","followers_url":"https://api.github.com/users/dmitrydi/followers","following_url":"https://api.github.com/users/dmitrydi/following{/other_user}","gists_url":"https://api.github.com/users/dmitrydi/gists{/gist_id}","starred_url":"https://api.github.com/users/dmitrydi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmitrydi/subscriptions","organizations_url":"https://api.github.com/users/dmitrydi/orgs","repos_url":"https://api.github.com/users/dmitrydi/repos","events_url":"https://api.github.com/users/dmitrydi/events{/privacy}","received_events_url":"https://api.github.com/users/dmitrydi/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-29T09:03:30Z","updated_at":"2016-08-08T13:59:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"09966c7cae9b52b3e2557b77d33f6ffc9b3b5ade","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dmitrydi/movie_pack/pulls/7/commits","review_comments_url":"https://api.github.com/repos/dmitrydi/movie_pack/pulls/7/comments","review_comment_url":"https://api.github.com/repos/dmitrydi/movie_pack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dmitrydi/movie_pack/issues/7/comments","statuses_url":"https://api.github.com/repos/dmitrydi/movie_pack/statuses/a3fd72a54e150e1f75b073f27a1d4fd2b093e547","head":{"label":"dmitrydi:task_10_diff","ref":"task_10_diff","sha":"a3fd72a54e150e1f75b073f27a1d4fd2b093e547","user":{"login":"dmitrydi","id":19414894,"avatar_url":"https://avatars.githubusercontent.com/u/19414894?v=3","gravatar_id":"","url":"https://api.github.com/users/dmitrydi","html_url":"https://github.com/dmitrydi","followers_url":"https://api.github.com/users/dmitrydi/followers","following_url":"https://api.github.com/users/dmitrydi/following{/other_user}","gists_url":"https://api.github.com/users/dmitrydi/gists{/gist_id}","starred_url":"https://api.github.com/users/dmitrydi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmitrydi/subscriptions","organizations_url":"https://api.github.com/users/dmitrydi/orgs","repos_url":"https://api.github.com/users/dmitrydi/repos","events_url":"https://api.github.com/users/dmitrydi/events{/privacy}","received_events_url":"https://api.github.com/users/dmitrydi/received_events","type":"User","site_admin":false},"repo":{"id":59932692,"name":"movie_pack","full_name":"dmitrydi/movie_pack","owner":{"login":"dmitrydi","id":19414894,"avatar_url":"https://avatars.githubusercontent.com/u/19414894?v=3","gravatar_id":"","url":"https://api.github.com/users/dmitrydi","html_url":"https://github.com/dmitrydi","followers_url":"https://api.github.com/users/dmitrydi/followers","following_url":"https://api.github.com/users/dmitrydi/following{/other_user}","gists_url":"https://api.github.com/users/dmitrydi/gists{/gist_id}","starred_url":"https://api.github.com/users/dmitrydi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmitrydi/subscriptions","organizations_url":"https://api.github.com/users/dmitrydi/orgs","repos_url":"https://api.github.com/users/dmitrydi/repos","events_url":"https://api.github.com/users/dmitrydi/events{/privacy}","received_events_url":"https://api.github.com/users/dmitrydi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dmitrydi/movie_pack","description":"Working with classes","fork":false,"url":"https://api.github.com/repos/dmitrydi/movie_pack","forks_url":"https://api.github.com/repos/dmitrydi/movie_pack/forks","keys_url":"https://api.github.com/repos/dmitrydi/movie_pack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dmitrydi/movie_pack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dmitrydi/movie_pack/teams","hooks_url":"https://api.github.com/repos/dmitrydi/movie_pack/hooks","issue_events_url":"https://api.github.com/repos/dmitrydi/movie_pack/issues/events{/number}","events_url":"https://api.github.com/repos/dmitrydi/movie_pack/events","assignees_url":"https://api.github.com/repos/dmitrydi/movie_pack/assignees{/user}","branches_url":"https://api.github.com/repos/dmitrydi/movie_pack/branches{/branch}","tags_url":"https://api.github.com/repos/dmitrydi/movie_pack/tags","blobs_url":"https://api.github.com/repos/dmitrydi/movie_pack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dmitrydi/movie_pack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dmitrydi/movie_pack/git/refs{/sha}","trees_url":"https://api.github.com/repos/dmitrydi/movie_pack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dmitrydi/movie_pack/statuses/{sha}","languages_url":"https://api.github.com/repos/dmitrydi/movie_pack/languages","stargazers_url":"https://api.github.com/repos/dmitrydi/movie_pack/stargazers","contributors_url":"https://api.github.com/repos/dmitrydi/movie_pack/contributors","subscribers_url":"https://api.github.com/repos/dmitrydi/movie_pack/subscribers","subscription_url":"https://api.github.com/repos/dmitrydi/movie_pack/subscription","commits_url":"https://api.github.com/repos/dmitrydi/movie_pack/commits{/sha}","git_commits_url":"https://api.github.com/repos/dmitrydi/movie_pack/git/commits{/sha}","comments_url":"https://api.github.com/repos/dmitrydi/movie_pack/comments{/number}","issue_comment_url":"https://api.github.com/repos/dmitrydi/movie_pack/issues/comments{/number}","contents_url":"https://api.github.com/repos/dmitrydi/movie_pack/contents/{+path}","compare_url":"https://api.github.com/repos/dmitrydi/movie_pack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dmitrydi/movie_pack/merges","archive_url":"https://api.github.com/repos/dmitrydi/movie_pack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dmitrydi/movie_pack/downloads","issues_url":"https://api.github.com/repos/dmitrydi/movie_pack/issues{/number}","pulls_url":"https://api.github.com/repos/dmitrydi/movie_pack/pulls{/number}","milestones_url":"https://api.github.com/repos/dmitrydi/movie_pack/milestones{/number}","notifications_url":"https://api.github.com/repos/dmitrydi/movie_pack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dmitrydi/movie_pack/labels{/name}","releases_url":"https://api.github.com/repos/dmitrydi/movie_pack/releases{/id}","deployments_url":"https://api.github.com/repos/dmitrydi/movie_pack/deployments","created_at":"2016-05-29T07:59:47Z","updated_at":"2016-06-21T12:05:45Z","pushed_at":"2016-07-29T12:49:10Z","git_url":"git://github.com/dmitrydi/movie_pack.git","ssh_url":"git@github.com:dmitrydi/movie_pack.git","clone_url":"https://github.com/dmitrydi/movie_pack.git","svn_url":"https://github.com/dmitrydi/movie_pack","homepage":null,"size":367,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"dmitrydi:master","ref":"master","sha":"0e3eb2269941957edf84fb109634d481011ab528","user":{"login":"dmitrydi","id":19414894,"avatar_url":"https://avatars.githubusercontent.com/u/19414894?v=3","gravatar_id":"","url":"https://api.github.com/users/dmitrydi","html_url":"https://github.com/dmitrydi","followers_url":"https://api.github.com/users/dmitrydi/followers","following_url":"https://api.github.com/users/dmitrydi/following{/other_user}","gists_url":"https://api.github.com/users/dmitrydi/gists{/gist_id}","starred_url":"https://api.github.com/users/dmitrydi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmitrydi/subscriptions","organizations_url":"https://api.github.com/users/dmitrydi/orgs","repos_url":"https://api.github.com/users/dmitrydi/repos","events_url":"https://api.github.com/users/dmitrydi/events{/privacy}","received_events_url":"https://api.github.com/users/dmitrydi/received_events","type":"User","site_admin":false},"repo":{"id":59932692,"name":"movie_pack","full_name":"dmitrydi/movie_pack","owner":{"login":"dmitrydi","id":19414894,"avatar_url":"https://avatars.githubusercontent.com/u/19414894?v=3","gravatar_id":"","url":"https://api.github.com/users/dmitrydi","html_url":"https://github.com/dmitrydi","followers_url":"https://api.github.com/users/dmitrydi/followers","following_url":"https://api.github.com/users/dmitrydi/following{/other_user}","gists_url":"https://api.github.com/users/dmitrydi/gists{/gist_id}","starred_url":"https://api.github.com/users/dmitrydi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmitrydi/subscriptions","organizations_url":"https://api.github.com/users/dmitrydi/orgs","repos_url":"https://api.github.com/users/dmitrydi/repos","events_url":"https://api.github.com/users/dmitrydi/events{/privacy}","received_events_url":"https://api.github.com/users/dmitrydi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dmitrydi/movie_pack","description":"Working with classes","fork":false,"url":"https://api.github.com/repos/dmitrydi/movie_pack","forks_url":"https://api.github.com/repos/dmitrydi/movie_pack/forks","keys_url":"https://api.github.com/repos/dmitrydi/movie_pack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dmitrydi/movie_pack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dmitrydi/movie_pack/teams","hooks_url":"https://api.github.com/repos/dmitrydi/movie_pack/hooks","issue_events_url":"https://api.github.com/repos/dmitrydi/movie_pack/issues/events{/number}","events_url":"https://api.github.com/repos/dmitrydi/movie_pack/events","assignees_url":"https://api.github.com/repos/dmitrydi/movie_pack/assignees{/user}","branches_url":"https://api.github.com/repos/dmitrydi/movie_pack/branches{/branch}","tags_url":"https://api.github.com/repos/dmitrydi/movie_pack/tags","blobs_url":"https://api.github.com/repos/dmitrydi/movie_pack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dmitrydi/movie_pack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dmitrydi/movie_pack/git/refs{/sha}","trees_url":"https://api.github.com/repos/dmitrydi/movie_pack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dmitrydi/movie_pack/statuses/{sha}","languages_url":"https://api.github.com/repos/dmitrydi/movie_pack/languages","stargazers_url":"https://api.github.com/repos/dmitrydi/movie_pack/stargazers","contributors_url":"https://api.github.com/repos/dmitrydi/movie_pack/contributors","subscribers_url":"https://api.github.com/repos/dmitrydi/movie_pack/subscribers","subscription_url":"https://api.github.com/repos/dmitrydi/movie_pack/subscription","commits_url":"https://api.github.com/repos/dmitrydi/movie_pack/commits{/sha}","git_commits_url":"https://api.github.com/repos/dmitrydi/movie_pack/git/commits{/sha}","comments_url":"https://api.github.com/repos/dmitrydi/movie_pack/comments{/number}","issue_comment_url":"https://api.github.com/repos/dmitrydi/movie_pack/issues/comments{/number}","contents_url":"https://api.github.com/repos/dmitrydi/movie_pack/contents/{+path}","compare_url":"https://api.github.com/repos/dmitrydi/movie_pack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dmitrydi/movie_pack/merges","archive_url":"https://api.github.com/repos/dmitrydi/movie_pack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dmitrydi/movie_pack/downloads","issues_url":"https://api.github.com/repos/dmitrydi/movie_pack/issues{/number}","pulls_url":"https://api.github.com/repos/dmitrydi/movie_pack/pulls{/number}","milestones_url":"https://api.github.com/repos/dmitrydi/movie_pack/milestones{/number}","notifications_url":"https://api.github.com/repos/dmitrydi/movie_pack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dmitrydi/movie_pack/labels{/name}","releases_url":"https://api.github.com/repos/dmitrydi/movie_pack/releases{/id}","deployments_url":"https://api.github.com/repos/dmitrydi/movie_pack/deployments","created_at":"2016-05-29T07:59:47Z","updated_at":"2016-06-21T12:05:45Z","pushed_at":"2016-07-29T12:49:10Z","git_url":"git://github.com/dmitrydi/movie_pack.git","ssh_url":"git@github.com:dmitrydi/movie_pack.git","clone_url":"https://github.com/dmitrydi/movie_pack.git","svn_url":"https://github.com/dmitrydi/movie_pack","homepage":null,"size":367,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dmitrydi/movie_pack/pulls/7"},"html":{"href":"https://github.com/dmitrydi/movie_pack/pull/7"},"issue":{"href":"https://api.github.com/repos/dmitrydi/movie_pack/issues/7"},"comments":{"href":"https://api.github.com/repos/dmitrydi/movie_pack/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/dmitrydi/movie_pack/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/dmitrydi/movie_pack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dmitrydi/movie_pack/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/dmitrydi/movie_pack/statuses/a3fd72a54e150e1f75b073f27a1d4fd2b093e547"}}}}
{"actor":{"display_login":"dmitrydi"}}