traviscline (owner)

Fork Of

gist: 20945 by garyhod... Ubiquity commands to search...

Revisions

gist: 49116 Download_button fork
public
Public Clone URL: git://gist.github.com/49116.git
Embed All Files: show embed
ubiquity-torrent.js #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/**
* 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/7/' + TorrentUbiquity.PCM[category.toUpperCase()];
   
  Utils.openUrlInBrowser('http://'+h+p,null);
}
  
});