{"action":"created","comment":{"url":"https://api.github.com/repos/Tribler/tribler/pulls/comments/63186519","id":63186519,"diff_hunk":"@@ -0,0 +1,467 @@\n+# coding=utf-8\n+\"\"\"\n+Written by Egbert Bouman, Mihai Capotă, Elric Milon, and Ardhi Putra Pratama H\n+Supported boosting sources\n+\"\"\"\n+import HTMLParser\n+import glob\n+import logging\n+import os\n+import random\n+import time\n+import urllib\n+from binascii import hexlify\n+from hashlib import sha1\n+\n+import libtorrent as lt\n+from twisted.internet import reactor\n+from twisted.internet.task import LoopingCall\n+from twisted.web.client import Agent, readBody\n+from twisted.web.http_headers import Headers\n+\n+from Tribler.Core.TorrentDef import TorrentDef\n+from Tribler.Core.simpledefs import NTFY_INSERT, NTFY_TORRENTS, NTFY_UPDATE\n+from Tribler.Core.version import version_id\n+from Tribler.Main.Utility.GuiDBHandler import startWorker\n+from Tribler.Main.Utility.GuiDBTuples import Torrent\n+from Tribler.Main.vwxGUI.GuiUtility import GUIUtility\n+from Tribler.community.allchannel.community import AllChannelCommunity\n+from Tribler.community.channel.community import ChannelCommunity\n+from Tribler.dispersy.exception import CommunityNotFoundException\n+from Tribler.dispersy.util import call_on_reactor_thread\n+\n+\n+class BoostingSource(object):\n+    \"\"\"\n+    Base class for boosting source. For now, it can be RSS, directory, and channel\n+    \"\"\"\n+\n+    def __init__(self, session, source, boost_settings, callback):\n+        self.session = session\n+        self.channelcast_db = session.lm.channelcast_db\n+\n+        self.torrents = {}\n+        self.source = source\n+        self.interval = boost_settings.source_interval\n+        self.max_torrents = boost_settings.max_torrents_per_source\n+        self.callback = callback\n+        self.archive = False\n+\n+        self.enabled = True\n+\n+        self.av_uprate = 0\n+        self.av_dwnrate = 0\n+        self.storage_used = 0\n+        self.ready = False\n+\n+        self.gui_util = GUIUtility.getInstance()","path":"Tribler/Policies/BoostingSource.py","position":57,"original_position":57,"commit_id":"b6480ed409b349a4bc38d5f97513fd9839f5efda","original_commit_id":"b6480ed409b349a4bc38d5f97513fd9839f5efda","user":{"login":"ardhipoetra","id":2739025,"avatar_url":"https://avatars.githubusercontent.com/u/2739025?v=3","gravatar_id":"","url":"https://api.github.com/users/ardhipoetra","html_url":"https://github.com/ardhipoetra","followers_url":"https://api.github.com/users/ardhipoetra/followers","following_url":"https://api.github.com/users/ardhipoetra/following{/other_user}","gists_url":"https://api.github.com/users/ardhipoetra/gists{/gist_id}","starred_url":"https://api.github.com/users/ardhipoetra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ardhipoetra/subscriptions","organizations_url":"https://api.github.com/users/ardhipoetra/orgs","repos_url":"https://api.github.com/users/ardhipoetra/repos","events_url":"https://api.github.com/users/ardhipoetra/events{/privacy}","received_events_url":"https://api.github.com/users/ardhipoetra/received_events","type":"User","site_admin":false},"body":"@whirm, I used `GUIUtility` to access the _managers_ (TorrentManager, ChannelManager, etc). Is there any other way to use manager aside from `GUIUtility`? It's not GUI-related, btw","created_at":"2016-05-13T13:56:49Z","updated_at":"2016-05-13T13:56:49Z","html_url":"https://github.com/Tribler/tribler/pull/2064#discussion_r63186519","pull_request_url":"https://api.github.com/repos/Tribler/tribler/pulls/2064","_links":{"self":{"href":"https://api.github.com/repos/Tribler/tribler/pulls/comments/63186519"},"html":{"href":"https://github.com/Tribler/tribler/pull/2064#discussion_r63186519"},"pull_request":{"href":"https://api.github.com/repos/Tribler/tribler/pulls/2064"}}},"pull_request":{"url":"https://api.github.com/repos/Tribler/tribler/pulls/2064","id":64983870,"html_url":"https://github.com/Tribler/tribler/pull/2064","diff_url":"https://github.com/Tribler/tribler/pull/2064.diff","patch_url":"https://github.com/Tribler/tribler/pull/2064.patch","issue_url":"https://api.github.com/repos/Tribler/tribler/issues/2064","number":2064,"state":"open","locked":false,"title":"WIP : First Credit mining prototype","user":{"login":"ardhipoetra","id":2739025,"avatar_url":"https://avatars.githubusercontent.com/u/2739025?v=3","gravatar_id":"","url":"https://api.github.com/users/ardhipoetra","html_url":"https://github.com/ardhipoetra","followers_url":"https://api.github.com/users/ardhipoetra/followers","following_url":"https://api.github.com/users/ardhipoetra/following{/other_user}","gists_url":"https://api.github.com/users/ardhipoetra/gists{/gist_id}","starred_url":"https://api.github.com/users/ardhipoetra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ardhipoetra/subscriptions","organizations_url":"https://api.github.com/users/ardhipoetra/orgs","repos_url":"https://api.github.com/users/ardhipoetra/repos","events_url":"https://api.github.com/users/ardhipoetra/events{/privacy}","received_events_url":"https://api.github.com/users/ardhipoetra/received_events","type":"User","site_admin":false},"body":"This PR handles first protoype of auto credit mining in Tribler. Actually, it has been mentioned in #573.\r\n\r\nSome GUI components change in home screen. Instead of showing most recent/popular video, list of popular channels is shown. Selecting (or unselect) those checkboxes will affect what channel that we will _mine_.\r\n\r\n![home-page](https://cloud.githubusercontent.com/assets/2739025/14215418/18113e48-f843-11e5-8a56-584a3899a6bd.png)\r\n\r\n\r\nA new GUI page called credit mining is there. Basically it didn't change much from #23. I just changed the adding/removing sources part (especially channels) to be done in single click. And now, each source has it's own statistics, and I keep the total statistics in the top part of the screen. Some source info also available in the right part.\r\n\r\n![cm-page](https://cloud.githubusercontent.com/assets/2739025/14214760/113b7358-f83f-11e5-897b-e5a83dabe058.png)\r\n\r\nMore in the core:\r\nWhen Tribler start the credit mining process, it will (by default) look for swarm that has less seeder ratio compared to all the peers. Tribler will auto-download those swarm, and maximize the ratio credit if possible. We also determined the ratio we want.\r\n\r\nSome progress shown in #1842. It includes (also some works that need to be done): \r\n\r\n- [x] revamped some GUI's (cc80e2619003e74ae037895c1bac7978e64799ee)\r\n- [x] Fixing known bugs from previous work (415efe5d773f69e6e780f396dbbe27498fbe3d69)\r\n- [ ] Dead tracker reduces performance (blacklisting OR completely integrate with central tracker management)\r\n- [x] DHT-only support (not perfect but will do for now) (ec2586ba6c8078d1211e2bfa199bc8760e3f3d23).\r\nBasically, it translates information we can get from peers discovered by DHT to swarm health (seeder/leecher)\r\n- [x] Main download (in _download_ screen) aware mechanism (cee0d5d0bfe4dc491a3434a28b83ba96f9e2f039).\r\nWe don't want main downloading activity become slower because of mining. Also, continue to download some stuff that already mined.\r\n- [x] DHT Performance evaluation -beta (nothing to do with Tribler code)\r\n","created_at":"2016-04-01T18:14:37Z","updated_at":"2016-05-13T13:56:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2709cc191f8bdec4952efa02638a6632c8129d7d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Tribler/tribler/pulls/2064/commits","review_comments_url":"https://api.github.com/repos/Tribler/tribler/pulls/2064/comments","review_comment_url":"https://api.github.com/repos/Tribler/tribler/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Tribler/tribler/issues/2064/comments","statuses_url":"https://api.github.com/repos/Tribler/tribler/statuses/b6480ed409b349a4bc38d5f97513fd9839f5efda","head":{"label":"ardhipoetra:credit_mining","ref":"credit_mining","sha":"b6480ed409b349a4bc38d5f97513fd9839f5efda","user":{"login":"ardhipoetra","id":2739025,"avatar_url":"https://avatars.githubusercontent.com/u/2739025?v=3","gravatar_id":"","url":"https://api.github.com/users/ardhipoetra","html_url":"https://github.com/ardhipoetra","followers_url":"https://api.github.com/users/ardhipoetra/followers","following_url":"https://api.github.com/users/ardhipoetra/following{/other_user}","gists_url":"https://api.github.com/users/ardhipoetra/gists{/gist_id}","starred_url":"https://api.github.com/users/ardhipoetra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ardhipoetra/subscriptions","organizations_url":"https://api.github.com/users/ardhipoetra/orgs","repos_url":"https://api.github.com/users/ardhipoetra/repos","events_url":"https://api.github.com/users/ardhipoetra/events{/privacy}","received_events_url":"https://api.github.com/users/ardhipoetra/received_events","type":"User","site_admin":false},"repo":{"id":47112361,"name":"tribler","full_name":"ardhipoetra/tribler","owner":{"login":"ardhipoetra","id":2739025,"avatar_url":"https://avatars.githubusercontent.com/u/2739025?v=3","gravatar_id":"","url":"https://api.github.com/users/ardhipoetra","html_url":"https://github.com/ardhipoetra","followers_url":"https://api.github.com/users/ardhipoetra/followers","following_url":"https://api.github.com/users/ardhipoetra/following{/other_user}","gists_url":"https://api.github.com/users/ardhipoetra/gists{/gist_id}","starred_url":"https://api.github.com/users/ardhipoetra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ardhipoetra/subscriptions","organizations_url":"https://api.github.com/users/ardhipoetra/orgs","repos_url":"https://api.github.com/users/ardhipoetra/repos","events_url":"https://api.github.com/users/ardhipoetra/events{/privacy}","received_events_url":"https://api.github.com/users/ardhipoetra/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ardhipoetra/tribler","description":"Privacy with BitTorrent and resilient to shut down","fork":true,"url":"https://api.github.com/repos/ardhipoetra/tribler","forks_url":"https://api.github.com/repos/ardhipoetra/tribler/forks","keys_url":"https://api.github.com/repos/ardhipoetra/tribler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ardhipoetra/tribler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ardhipoetra/tribler/teams","hooks_url":"https://api.github.com/repos/ardhipoetra/tribler/hooks","issue_events_url":"https://api.github.com/repos/ardhipoetra/tribler/issues/events{/number}","events_url":"https://api.github.com/repos/ardhipoetra/tribler/events","assignees_url":"https://api.github.com/repos/ardhipoetra/tribler/assignees{/user}","branches_url":"https://api.github.com/repos/ardhipoetra/tribler/branches{/branch}","tags_url":"https://api.github.com/repos/ardhipoetra/tribler/tags","blobs_url":"https://api.github.com/repos/ardhipoetra/tribler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ardhipoetra/tribler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ardhipoetra/tribler/git/refs{/sha}","trees_url":"https://api.github.com/repos/ardhipoetra/tribler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ardhipoetra/tribler/statuses/{sha}","languages_url":"https://api.github.com/repos/ardhipoetra/tribler/languages","stargazers_url":"https://api.github.com/repos/ardhipoetra/tribler/stargazers","contributors_url":"https://api.github.com/repos/ardhipoetra/tribler/contributors","subscribers_url":"https://api.github.com/repos/ardhipoetra/tribler/subscribers","subscription_url":"https://api.github.com/repos/ardhipoetra/tribler/subscription","commits_url":"https://api.github.com/repos/ardhipoetra/tribler/commits{/sha}","git_commits_url":"https://api.github.com/repos/ardhipoetra/tribler/git/commits{/sha}","comments_url":"https://api.github.com/repos/ardhipoetra/tribler/comments{/number}","issue_comment_url":"https://api.github.com/repos/ardhipoetra/tribler/issues/comments{/number}","contents_url":"https://api.github.com/repos/ardhipoetra/tribler/contents/{+path}","compare_url":"https://api.github.com/repos/ardhipoetra/tribler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ardhipoetra/tribler/merges","archive_url":"https://api.github.com/repos/ardhipoetra/tribler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ardhipoetra/tribler/downloads","issues_url":"https://api.github.com/repos/ardhipoetra/tribler/issues{/number}","pulls_url":"https://api.github.com/repos/ardhipoetra/tribler/pulls{/number}","milestones_url":"https://api.github.com/repos/ardhipoetra/tribler/milestones{/number}","notifications_url":"https://api.github.com/repos/ardhipoetra/tribler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ardhipoetra/tribler/labels{/name}","releases_url":"https://api.github.com/repos/ardhipoetra/tribler/releases{/id}","deployments_url":"https://api.github.com/repos/ardhipoetra/tribler/deployments","created_at":"2015-11-30T10:47:06Z","updated_at":"2016-01-26T15:20:10Z","pushed_at":"2016-05-13T09:24:14Z","git_url":"git://github.com/ardhipoetra/tribler.git","ssh_url":"git@github.com:ardhipoetra/tribler.git","clone_url":"https://github.com/ardhipoetra/tribler.git","svn_url":"https://github.com/ardhipoetra/tribler","homepage":"http://www.tribler.org","size":114352,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"devel"}},"base":{"label":"Tribler:devel","ref":"devel","sha":"b60d3b126ddfcafc2a939c32ca6b9a97a962f561","user":{"login":"Tribler","id":2913489,"avatar_url":"https://avatars.githubusercontent.com/u/2913489?v=3","gravatar_id":"","url":"https://api.github.com/users/Tribler","html_url":"https://github.com/Tribler","followers_url":"https://api.github.com/users/Tribler/followers","following_url":"https://api.github.com/users/Tribler/following{/other_user}","gists_url":"https://api.github.com/users/Tribler/gists{/gist_id}","starred_url":"https://api.github.com/users/Tribler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tribler/subscriptions","organizations_url":"https://api.github.com/users/Tribler/orgs","repos_url":"https://api.github.com/users/Tribler/repos","events_url":"https://api.github.com/users/Tribler/events{/privacy}","received_events_url":"https://api.github.com/users/Tribler/received_events","type":"Organization","site_admin":false},"repo":{"id":8411137,"name":"tribler","full_name":"Tribler/tribler","owner":{"login":"Tribler","id":2913489,"avatar_url":"https://avatars.githubusercontent.com/u/2913489?v=3","gravatar_id":"","url":"https://api.github.com/users/Tribler","html_url":"https://github.com/Tribler","followers_url":"https://api.github.com/users/Tribler/followers","following_url":"https://api.github.com/users/Tribler/following{/other_user}","gists_url":"https://api.github.com/users/Tribler/gists{/gist_id}","starred_url":"https://api.github.com/users/Tribler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tribler/subscriptions","organizations_url":"https://api.github.com/users/Tribler/orgs","repos_url":"https://api.github.com/users/Tribler/repos","events_url":"https://api.github.com/users/Tribler/events{/privacy}","received_events_url":"https://api.github.com/users/Tribler/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Tribler/tribler","description":"Privacy with BitTorrent and resilient to shut down","fork":false,"url":"https://api.github.com/repos/Tribler/tribler","forks_url":"https://api.github.com/repos/Tribler/tribler/forks","keys_url":"https://api.github.com/repos/Tribler/tribler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Tribler/tribler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Tribler/tribler/teams","hooks_url":"https://api.github.com/repos/Tribler/tribler/hooks","issue_events_url":"https://api.github.com/repos/Tribler/tribler/issues/events{/number}","events_url":"https://api.github.com/repos/Tribler/tribler/events","assignees_url":"https://api.github.com/repos/Tribler/tribler/assignees{/user}","branches_url":"https://api.github.com/repos/Tribler/tribler/branches{/branch}","tags_url":"https://api.github.com/repos/Tribler/tribler/tags","blobs_url":"https://api.github.com/repos/Tribler/tribler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Tribler/tribler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Tribler/tribler/git/refs{/sha}","trees_url":"https://api.github.com/repos/Tribler/tribler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Tribler/tribler/statuses/{sha}","languages_url":"https://api.github.com/repos/Tribler/tribler/languages","stargazers_url":"https://api.github.com/repos/Tribler/tribler/stargazers","contributors_url":"https://api.github.com/repos/Tribler/tribler/contributors","subscribers_url":"https://api.github.com/repos/Tribler/tribler/subscribers","subscription_url":"https://api.github.com/repos/Tribler/tribler/subscription","commits_url":"https://api.github.com/repos/Tribler/tribler/commits{/sha}","git_commits_url":"https://api.github.com/repos/Tribler/tribler/git/commits{/sha}","comments_url":"https://api.github.com/repos/Tribler/tribler/comments{/number}","issue_comment_url":"https://api.github.com/repos/Tribler/tribler/issues/comments{/number}","contents_url":"https://api.github.com/repos/Tribler/tribler/contents/{+path}","compare_url":"https://api.github.com/repos/Tribler/tribler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Tribler/tribler/merges","archive_url":"https://api.github.com/repos/Tribler/tribler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Tribler/tribler/downloads","issues_url":"https://api.github.com/repos/Tribler/tribler/issues{/number}","pulls_url":"https://api.github.com/repos/Tribler/tribler/pulls{/number}","milestones_url":"https://api.github.com/repos/Tribler/tribler/milestones{/number}","notifications_url":"https://api.github.com/repos/Tribler/tribler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Tribler/tribler/labels{/name}","releases_url":"https://api.github.com/repos/Tribler/tribler/releases{/id}","deployments_url":"https://api.github.com/repos/Tribler/tribler/deployments","created_at":"2013-02-25T14:51:58Z","updated_at":"2016-05-12T22:39:29Z","pushed_at":"2016-05-13T13:44:36Z","git_url":"git://github.com/Tribler/tribler.git","ssh_url":"git@github.com:Tribler/tribler.git","clone_url":"https://github.com/Tribler/tribler.git","svn_url":"https://github.com/Tribler/tribler","homepage":"http://www.tribler.org","size":132387,"stargazers_count":1872,"watchers_count":1872,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":201,"mirror_url":null,"open_issues_count":275,"forks":201,"open_issues":275,"watchers":1872,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/Tribler/tribler/pulls/2064"},"html":{"href":"https://github.com/Tribler/tribler/pull/2064"},"issue":{"href":"https://api.github.com/repos/Tribler/tribler/issues/2064"},"comments":{"href":"https://api.github.com/repos/Tribler/tribler/issues/2064/comments"},"review_comments":{"href":"https://api.github.com/repos/Tribler/tribler/pulls/2064/comments"},"review_comment":{"href":"https://api.github.com/repos/Tribler/tribler/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Tribler/tribler/pulls/2064/commits"},"statuses":{"href":"https://api.github.com/repos/Tribler/tribler/statuses/b6480ed409b349a4bc38d5f97513fd9839f5efda"}}}}