Skip to content

Instantly share code, notes, and snippets.

@ba3r
Created January 4, 2010 15:17
Show Gist options
  • Save ba3r/268573 to your computer and use it in GitHub Desktop.
Save ba3r/268573 to your computer and use it in GitHub Desktop.
noun_type_btcat = new CmdUtils.NounType( "category",
["Audio", "Music", "Games", "Software", "Applications", "TV", "Series", "Unsorted", "None", "Video", "Movies", "Anime", "Manga", "XXX", "Porn"]
);
CmdUtils.CreateCommand({
names: ["btjunkie"],
icon: "http://btjunkie.org/favicon.ico",
homepage: "http://btjunkie.org",
author: { name: "Michael Baer", homepage: "http://twitter.com/synapsos"},
license: "GPL",
description: "Searches for torrents using BTJunkie",
help: "Type or select search terms",
arguments: {object_query: noun_arb_text,
location_category: noun_type_btcat},
preview: function( pblock, args) {
pblock.innerHTML = "";
var msg = "Search BTJunkie for <b>${query}</b> in <b>${cat}</b>";
var prev = "<iframe src='http://itde.vccs.edu/rss2js/feed2js.php?src=http%3A%2F%2Fbtjunkie.org%2Frss.xml%3Fquery%3D" + args.object.text + "&chan=n&num=3&desc=0&date=n&targ=n'>Loading oreview... </iframe>";
var subs = {query: args.object.text, cat: args.location.text};
pblock.innerHTML = CmdUtils.renderTemplate( msg, prev, subs );
},
execute: function(args) {
var query = args.object.text.replace(/\s/, "+");
var cat = args.location.text;
if (cat == "Audio" || cat == "Music") {cat = "1"} else {
if (cat == "Games") {cat = "2"} else {
if (cat == "Software" || cat == "Applications") {cat = "3"} else {
if (cat == "TV" || cat == "Series") {cat = "4"} else {
if (cat == "Unsorted" || cat == "None") {cat = "5"} else {
if (cat == "Video" || cat == "Movies") {cat = "6"} else {
if (cat == "Anime" || cat == "Manga") {cat = "7"} else {
if (cat == "XXX" || cat == "Porn") {cat = "8"} else {
}}}}}}}};
Utils.openUrlInBrowser("http://btjunkie.org/search?q="+ query + "&c=" + cat);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment