{"action":"created","issue":{"url":"https://api.github.com/repos/Ivshti/multipass-torrent/issues/7","labels_url":"https://api.github.com/repos/Ivshti/multipass-torrent/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/Ivshti/multipass-torrent/issues/7/comments","events_url":"https://api.github.com/repos/Ivshti/multipass-torrent/issues/7/events","html_url":"https://github.com/Ivshti/multipass-torrent/issues/7","id":104509936,"number":7,"title":"Preference system similar to Stremio's in lib/db","user":{"login":"Ivshti","id":1247629,"avatar_url":"https://avatars.githubusercontent.com/u/1247629?v=3","gravatar_id":"","url":"https://api.github.com/users/Ivshti","html_url":"https://github.com/Ivshti","followers_url":"https://api.github.com/users/Ivshti/followers","following_url":"https://api.github.com/users/Ivshti/following{/other_user}","gists_url":"https://api.github.com/users/Ivshti/gists{/gist_id}","starred_url":"https://api.github.com/users/Ivshti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ivshti/subscriptions","organizations_url":"https://api.github.com/users/Ivshti/orgs","repos_url":"https://api.github.com/users/Ivshti/repos","events_url":"https://api.github.com/users/Ivshti/events{/privacy}","received_events_url":"https://api.github.com/users/Ivshti/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-09-02T15:34:45Z","updated_at":"2015-09-06T18:34:10Z","closed_at":null,"body":"It would work like\r\n```javascript\r\ndb.findOne({  imdb_id: ...},[\r\n   { tag: \"hd\", min_avail: 2 } // prefer HD torrents if they have at least 2 availability\r\n], function(err, torrent) { /* receive torrent */ })\r\n```\r\n\r\nIt must be default behaviour to prefer 720p and 1080p torrents if their availability is at least 2"},"comment":{"url":"https://api.github.com/repos/Ivshti/multipass-torrent/issues/comments/138109256","html_url":"https://github.com/Ivshti/multipass-torrent/issues/7#issuecomment-138109256","issue_url":"https://api.github.com/repos/Ivshti/multipass-torrent/issues/7","id":138109256,"user":{"login":"Ivshti","id":1247629,"avatar_url":"https://avatars.githubusercontent.com/u/1247629?v=3","gravatar_id":"","url":"https://api.github.com/users/Ivshti","html_url":"https://github.com/Ivshti","followers_url":"https://api.github.com/users/Ivshti/followers","following_url":"https://api.github.com/users/Ivshti/following{/other_user}","gists_url":"https://api.github.com/users/Ivshti/gists{/gist_id}","starred_url":"https://api.github.com/users/Ivshti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ivshti/subscriptions","organizations_url":"https://api.github.com/users/Ivshti/orgs","repos_url":"https://api.github.com/users/Ivshti/repos","events_url":"https://api.github.com/users/Ivshti/events{/privacy}","received_events_url":"https://api.github.com/users/Ivshti/received_events","type":"User","site_admin":false},"created_at":"2015-09-06T18:34:10Z","updated_at":"2015-09-06T18:34:10Z","body":"IMO this should be a separate function. Most of the code to do this stuff is the stremio add-on in the repo, using output from db.lookup + db.get (essentially a db.find, but without getting all torrents at once), getting the picked file (the file in the torrent which corresponds to the query) and deciding if it contains a preferred tag (such as hd) in the .tag array.\r\n\r\nLet's summarize how we imagine this and merge with the simplify API issue and roll out the events API and this at the same time as 0.2 release?\r\n\r\nIMO if we have ``db.findOne(query, preferred)``, grouping by quali won't be necessary"}}