Skip to content

Instantly share code, notes, and snippets.

@garyhodgson
Created October 30, 2008 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save garyhodgson/20945 to your computer and use it in GitHub Desktop.
Save garyhodgson/20945 to your computer and use it in GitHub Desktop.
Ubiquity commands to search mininova.org or thepiratebay.org
/**
* Ubiquity commands to search mininova.org or thepiratebay.org
*/
var TorrentUbiquity = {};
TorrentUbiquity.MCM = {
'ANIME' : '1',
'BOOKS' : '2',
'GAMES' : '3',
'MOVIES' : '4',
'MUSIC' : '5',
'PICTURES' : '6',
'SOFTWARE' : '7',
'TV SHOWS' : '8',
'OTHER' : '9'
};
TorrentUbiquity.MininovaCategories = [
'Anime',
'Books',
'Games',
'Movies',
'Music',
'Pictures',
'Software',
'TV shows',
'Other'
];
TorrentUbiquity.noun_type_mincats= new CmdUtils.NounType( "Category", TorrentUbiquity.MininovaCategories );
CmdUtils.CreateCommand({
name: "mininova",
author: { name: "Gary Hodgson", homepage : "http://www.garyhodgson.com/", email : "contact@garyhodgson.com"},
icon: "http://static.mininova.org/images/favicon.ico",
homepage: "http://garyhodgson/ubiquity",
license: "MPL",
releaseinfo: {2:"(01 Sep 2008) Replaced openUrl with Utils.openUrlInBrowser.",
1:"(29 Aug 2008) Initial Release." },
description: "Performs a search on mininova.",
help: "A category can be defined to limit the result set, e.g. 'in Books'",
takes: {"torrent" : noun_arb_text},
modifiers: {"in" : TorrentUbiquity.noun_type_mincats},
preview: function( pblock, searchText, mods ) {
pblock.innerHTML = "";
var msg = 'Search Mininova for : ${search} in ${category}, and sort by most seeders.';
var subs = {search: searchText.text, category: (mods.in.text||'')};
pblock.innerHTML = CmdUtils.renderTemplate( msg, subs );
},
execute: function( searchText, mods ) {
h='www.mininova.org';
var category = mods.in.text||'';
var catid = ( TorrentUbiquity.MCM[category.toUpperCase()] ? '/'+TorrentUbiquity.MCM[category.toUpperCase()] : '');
p='/search/'+encodeURIComponent(searchText.text) + catid + '/seeds';
cp='http://'+h+p;
Utils.openUrlInBrowser(cp,null);
}
});
CmdUtils.CreateCommand({
name: "mininova-imdb",
author: { name: "Gary Hodgson", homepage : "http://www.garyhodgson.com/", email : "contact@garyhodgson.com"},
icon: "http://static.mininova.org/images/favicon.ico",
homepage: "http://garyhodgson/ubiquity",
license: "MPL",
releaseinfo: {2:"(01 Sep 2008) Replaced openUrl with Utils.openUrlInBrowser.",
1:"(29 Aug 2008) Initial Release."},
description: "Searches mininova for torrents associated with the given IMDB reference.",
help: "IMDB references can include the tt prefix or not.",
takes: {"imdbid" : noun_arb_text},
preview: function( pblock, searchText, mods ) {
pblock.innerHTML = "";
var msg = 'Search Mininova for : ${imdbid} , using an IMDB reference.';
var subs = {imdbid: searchText.text};
pblock.innerHTML = CmdUtils.renderTemplate( msg, subs );
},
execute: function( searchText, mods ) {
h='www.mininova.org';
var imdbid = ( (! searchText.text.indexOf("tt")) ? searchText.text.slice(2) : searchText.text);
p='/imdb/?imdb='+imdbid;
cp='http://'+h+p;
Utils.openUrlInBrowser(cp,null);
}
});
TorrentUbiquity.PCM = {
'AUDIO' : '100',
'VIDEO' : '200',
'SOFTWARE' : '300',
'GAMES' : '400',
'OTHER' : '600'
};
TorrentUbiquity.PirateCategories = [
'Audio',
'Video',
'Software',
'Games',
'Other'
];
TorrentUbiquity.noun_type_piratecats= new CmdUtils.NounType( "Category", TorrentUbiquity.PirateCategories );
CmdUtils.CreateCommand({
name: "piratebay",
description: "Performs a search on The Pirate Bay.",
icon: "http://www.google.com/s2/favicons?domain=www.thepiratebay.org",
author: { name: "Gary Hodgson", homepage : "http://www.garyhodgson.com/", email : "contact@garyhodgson.com"},
contributors: {name: "Axel Boldt"},
homepage: "http://garyhodgson.com",
license: "MPL",
releaseinfo: {1:"(04 Sep 2008) Initial Release, inspired by a command by <a href='http://math-www.uni-paderborn.de/~axel/'>Axel Boldt</a>" },
takes: {"torrent" : noun_arb_text},
modifiers: {"in" : TorrentUbiquity.noun_type_piratecats},
preview: function( pblock, searchText, mods ) {
pblock.innerHTML = "";
var msg = 'Search PirateBay for : ${search} in ${category}';
var subs = {search: searchText.text, category: (mods.in.text||'')};
pblock.innerHTML = CmdUtils.renderTemplate( msg, subs );
},
execute: function( searchText, mods ) {
var category = mods.in.text||'';
h='thepiratebay.org';
p='/search/'+encodeURIComponent(searchText.text) + '/0/99/' + TorrentUbiquity.PCM[category.toUpperCase()];
Utils.openUrlInBrowser('http://'+h+p,null);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment