{"action":"created","issue":{"url":"https://api.github.com/repos/SiCKRAGETV/SickRage/issues/1958","labels_url":"https://api.github.com/repos/SiCKRAGETV/SickRage/issues/1958/labels{/name}","comments_url":"https://api.github.com/repos/SiCKRAGETV/SickRage/issues/1958/comments","events_url":"https://api.github.com/repos/SiCKRAGETV/SickRage/issues/1958/events","html_url":"https://github.com/SiCKRAGETV/SickRage/pull/1958","id":88214238,"number":1958,"title":"Add API methods to check for update and perform update","user":{"login":"MGaetan89","id":1009664,"avatar_url":"https://avatars.githubusercontent.com/u/1009664?v=3","gravatar_id":"","url":"https://api.github.com/users/MGaetan89","html_url":"https://github.com/MGaetan89","followers_url":"https://api.github.com/users/MGaetan89/followers","following_url":"https://api.github.com/users/MGaetan89/following{/other_user}","gists_url":"https://api.github.com/users/MGaetan89/gists{/gist_id}","starred_url":"https://api.github.com/users/MGaetan89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MGaetan89/subscriptions","organizations_url":"https://api.github.com/users/MGaetan89/orgs","repos_url":"https://api.github.com/users/MGaetan89/repos","events_url":"https://api.github.com/users/MGaetan89/events{/privacy}","received_events_url":"https://api.github.com/users/MGaetan89/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/SiCKRAGETV/SickRage/labels/Do%20Not%20Merge","name":"Do Not Merge","color":"e11d21"},{"url":"https://api.github.com/repos/SiCKRAGETV/SickRage/labels/Feature","name":"Feature","color":"0052cc"},{"url":"https://api.github.com/repos/SiCKRAGETV/SickRage/labels/Need%20to%20be%20tested","name":"Need to be tested","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":36,"created_at":"2015-06-14T16:52:17Z","updated_at":"2015-07-14T18:40:03Z","closed_at":"2015-07-08T08:20:20Z","pull_request":{"url":"https://api.github.com/repos/SiCKRAGETV/SickRage/pulls/1958","html_url":"https://github.com/SiCKRAGETV/SickRage/pull/1958","diff_url":"https://github.com/SiCKRAGETV/SickRage/pull/1958.diff","patch_url":"https://github.com/SiCKRAGETV/SickRage/pull/1958.patch"},"body":"I added the two following methods to SickRage's API:\r\n- `sb.checkversion`:\r\n - Get information about the current version\r\n - Get information about the latest version\r\n - Check if an update is required\r\n - Get the number of commits between the current version and the latest version\r\n- `sb.update`: update SickRage if necessary\r\n\r\n## Usage\r\n\r\n### `sb.checkversion`\r\n\r\nRequest:\r\n\r\n```\r\nGET /?cmd=sb.checkversion\r\n```\r\n\r\nResponse:\r\n\r\n```json\r\n{\r\n    \"data\": {\r\n        \"commits_offset\": 0, \r\n        \"current_version\": {\r\n            \"branch\": \"develop\", \r\n            \"commit\": \"ddc0fca21d9030612a5c810ecc24463a7f64112b\", \r\n            \"version\": \"v4.0.24\"\r\n        }, \r\n        \"latest_version\": {\r\n            \"branch\": \"develop\", \r\n            \"commit\": \"3565ec70dc924d8117f506983fc18a9351f487e4\", \r\n            \"version\": \"v4.0.24\"\r\n        }, \r\n        \"needs_update\": false\r\n    }, \r\n    \"message\": \"\", \r\n    \"result\": \"success\"\r\n}\r\n```\r\n\r\n### `sb.update`\r\n\r\nRequest:\r\n\r\n```\r\nGET /?cmd=sb.update\r\n```\r\n\r\nResponse:\r\n\r\n```json\r\n// If no update is necessary\r\n{\r\n    \"data\": {}, \r\n    \"message\": \"SickRage is already up to date\", \r\n    \"result\": \"failure\"\r\n}\r\n\r\n// If the config could not be backed up\r\n{\r\n    \"data\": {}, \r\n    \"message\": \"SickRage could not backup config ...\", \r\n    \"result\": \"failure\"\r\n}\r\n\r\n// If an update was started\r\n{\r\n    \"data\": {}, \r\n    \"message\": \"SickRage is updating ...\", \r\n    \"result\": \"success\"\r\n}\r\n```\r\n\r\nI'm not an expert in Python, but I think that my changes in `sickbeard/versionChecker.py` can be improved.\r\n\r\nReference issue: SiCKRAGETV/sickrage-issues#1780"},"comment":{"url":"https://api.github.com/repos/SiCKRAGETV/SickRage/issues/comments/121336860","html_url":"https://github.com/SiCKRAGETV/SickRage/pull/1958#issuecomment-121336860","issue_url":"https://api.github.com/repos/SiCKRAGETV/SickRage/issues/1958","id":121336860,"user":{"login":"miigotu","id":390379,"avatar_url":"https://avatars.githubusercontent.com/u/390379?v=3","gravatar_id":"","url":"https://api.github.com/users/miigotu","html_url":"https://github.com/miigotu","followers_url":"https://api.github.com/users/miigotu/followers","following_url":"https://api.github.com/users/miigotu/following{/other_user}","gists_url":"https://api.github.com/users/miigotu/gists{/gist_id}","starred_url":"https://api.github.com/users/miigotu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miigotu/subscriptions","organizations_url":"https://api.github.com/users/miigotu/orgs","repos_url":"https://api.github.com/users/miigotu/repos","events_url":"https://api.github.com/users/miigotu/events{/privacy}","received_events_url":"https://api.github.com/users/miigotu/received_events","type":"User","site_admin":false},"created_at":"2015-07-14T18:40:03Z","updated_at":"2015-07-14T18:40:03Z","body":"Thats why the message is \"attempting\""}}