├── api
├── web
│ └── .gitkeep
├── .gitignore
├── scheduler.go
├── Dockerfile
├── api.go
├── scrape.go
├── config.json
├── Makefile
├── bitcannon.go
├── import.go
└── torrentdb.go
├── web
├── app
│ ├── .buildignore
│ ├── robots.txt
│ ├── favicon.ico
│ ├── images
│ │ └── bitcannon.png
│ ├── views
│ │ ├── browse.html
│ │ ├── main.html
│ │ ├── about.html
│ │ ├── last.html
│ │ ├── search.html
│ │ └── torrent.html
│ ├── scripts
│ │ ├── controllers
│ │ │ ├── browse.js
│ │ │ ├── main.js
│ │ │ ├── settings.js
│ │ │ ├── browsesearch.js
│ │ │ ├── last.js
│ │ │ ├── search.js
│ │ │ └── torrent.js
│ │ └── app.js
│ ├── styles
│ │ └── main.css
│ ├── 404.html
│ └── index.html
├── .gitattributes
├── .bowerrc
├── .gitignore
├── .travis.yml
├── index.js
├── Dockerfile
├── .jshintrc
├── .editorconfig
├── bower.json
├── test
│ ├── spec
│ │ └── controllers
│ │ │ ├── main.js
│ │ │ ├── browse.js
│ │ │ ├── search.js
│ │ │ ├── torrent.js
│ │ │ ├── settings.js
│ │ │ └── browsesearch.js
│ ├── .jshintrc
│ └── karma.conf.js
├── package.json
└── Gruntfile.js
├── .gitignore
├── Makefile
├── docker-compose.yml
├── LICENSE.md
└── README.md
/api/web/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/web/app/.buildignore:
--------------------------------------------------------------------------------
1 | *.coffee
--------------------------------------------------------------------------------
/web/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | BitCannon.zip
2 | data/
3 |
--------------------------------------------------------------------------------
/api/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | web/
3 | bindata.go
4 |
--------------------------------------------------------------------------------
/web/.bowerrc:
--------------------------------------------------------------------------------
1 | {
2 | "directory": "bower_components"
3 | }
4 |
--------------------------------------------------------------------------------
/web/app/robots.txt:
--------------------------------------------------------------------------------
1 | # robotstxt.org
2 |
3 | User-agent: *
4 |
--------------------------------------------------------------------------------
/web/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | .tmp
4 | .sass-cache
5 | bower_components
6 |
--------------------------------------------------------------------------------
/web/app/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlyersWeb/bitcannon/HEAD/web/app/favicon.ico
--------------------------------------------------------------------------------
/web/app/images/bitcannon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlyersWeb/bitcannon/HEAD/web/app/images/bitcannon.png
--------------------------------------------------------------------------------
/web/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - '0.10'
4 | before_script:
5 | - 'npm install -g bower grunt-cli'
6 | - 'bower install'
7 |
--------------------------------------------------------------------------------
/api/scheduler.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import ()
4 |
5 | func runScheduler() {
6 | go importScheduler()
7 | if config.ScrapeEnabled {
8 | go scrapeWorker()
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/web/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const PORT = 9000;
4 | const express = require('express');
5 | const app = express();
6 |
7 | app.use(express.static('dist'));
8 |
9 | app.listen(PORT, function () {
10 | console.log(`Example app listening on port ${PORT}!`);
11 | });
12 |
--------------------------------------------------------------------------------
/web/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:5
2 |
3 | ADD . /var/www
4 | WORKDIR /var/www
5 |
6 | RUN npm install -g bower \
7 | && npm install -g grunt-cli \
8 | && rm -rf node_modules && rm -rf bower-components && rm -rf dist \
9 | && npm install
10 | RUN bower install --allow-root=true --config.analytics=false --config.interactive=false
11 | RUN grunt
12 |
13 | EXPOSE 3000
14 | CMD ["npm", "start"]
15 |
--------------------------------------------------------------------------------
/web/app/views/browse.html:
--------------------------------------------------------------------------------
1 |
2 |

3 |
13 |
{{stats.Count}} torrents in the database
14 |
15 |
--------------------------------------------------------------------------------
/web/test/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "node": true,
3 | "browser": true,
4 | "esnext": true,
5 | "bitwise": true,
6 | "camelcase": true,
7 | "curly": true,
8 | "eqeqeq": true,
9 | "immed": true,
10 | "indent": 2,
11 | "latedef": true,
12 | "newcap": true,
13 | "noarg": true,
14 | "quotmark": "single",
15 | "regexp": true,
16 | "undef": true,
17 | "unused": true,
18 | "strict": true,
19 | "trailing": true,
20 | "smarttabs": true,
21 | "globals": {
22 | "after": false,
23 | "afterEach": false,
24 | "angular": false,
25 | "before": false,
26 | "beforeEach": false,
27 | "browser": false,
28 | "describe": false,
29 | "expect": false,
30 | "inject": false,
31 | "it": false,
32 | "jasmine": false,
33 | "spyOn": false
34 | }
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/web/app/scripts/controllers/main.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc function
5 | * @name bitCannonApp.controller:MainCtrl
6 | * @description
7 | * # MainCtrl
8 | * Controller of the bitCannonApp
9 | */
10 | angular.module('bitCannonApp')
11 | .controller('MainCtrl', function($scope, $state) {
12 | $scope.awesomeThings = [
13 | 'HTML5 Boilerplate',
14 | 'AngularJS',
15 | 'Karma'
16 | ];
17 | $scope.submit = function() {
18 | if ($scope.query) {
19 | if ($scope.selectedCategory) {
20 | $state.go('searchCategory', {
21 | query: $scope.query,
22 | category: $scope.selectedCategory.name
23 | });
24 | } else {
25 | $state.go('search', {
26 | query: $scope.query
27 | });
28 | }
29 | }
30 | };
31 | });
32 |
--------------------------------------------------------------------------------
/web/app/scripts/controllers/settings.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc function
5 | * @name bitCannonApp.controller:SettingsCtrl
6 | * @description
7 | * # SettingsCtrl
8 | * Controller of the bitCannonApp
9 | */
10 | angular.module('bitCannonApp')
11 | .controller('SettingsCtrl', function ($rootScope, $scope, $window) {
12 | $scope.awesomeThings = [
13 | 'HTML5 Boilerplate',
14 | 'AngularJS',
15 | 'Karma'
16 | ];
17 | $scope.saveAPI = function() {
18 | $rootScope.api = $scope.apiBox;
19 | $window.localStorage.api = $rootScope.api;
20 | };
21 | $scope.clearAPIBox = function() {
22 | $scope.apiBox = $rootScope.api;
23 | };
24 | $scope.resetAPI = function() {
25 | delete $window.localStorage.api;
26 | $rootScope.api = '';// Old default http://localhost:1337
27 | $scope.apiBox = $rootScope.api;
28 | };
29 | $scope.apiBox = $rootScope.api;
30 | });
31 |
--------------------------------------------------------------------------------
/web/app/views/about.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | The BitCannon Project
4 |
5 |
6 | Visit bitcannon.io for more info
7 |
8 |
9 | The goal of BitCannon is to provide the tools to easily aggregate the content of many torrent sites into an easily browse-able format.
10 |
11 |
BitCannon aims to be as user friendly as possible while still providing robustness and the features you would expect. We hope the average user will use BitCannon to keep personal bittorrent archives, but we strive to produce code that can stand up
12 | to running a public mirror as well.
13 |
14 |
15 | How To Use
16 |
17 |
18 | Using BitCannon is simple. There is a search box on the front page that allows you to search for torrents that have been loaded into the database. You may also find torrents using the browse tab. The torrent decsription page contains torrent details and
19 | a magnet link, which will open your torrent client for downloading.
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 BitCannon Team
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/web/app/scripts/controllers/browsesearch.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc function
5 | * @name bitCannonApp.controller:BrowsesearchCtrl
6 | * @description
7 | * # BrowsesearchCtrl
8 | * Controller of the bitCannonApp
9 | */
10 | angular.module('bitCannonApp')
11 | .controller('BrowsesearchCtrl', function ($rootScope, $scope, $stateParams, $http) {
12 | $scope.awesomeThings = [
13 | 'HTML5 Boilerplate',
14 | 'AngularJS',
15 | 'Karma'
16 | ];
17 | $scope.category = $stateParams.category;
18 | var init = function() {
19 | $http.get($rootScope.api + 'browse/' + $scope.category).
20 | success(function(data, status) {
21 | if (status === 200) {
22 | for (var i = 0; i < data.length; i++) {
23 | var row = data[i];
24 | row.Details = '&tr='+row.Details.join('&tr=');
25 | }
26 | $scope.results = data;
27 | }
28 | else {
29 | $rootScope.message = data.message;
30 | }
31 | }).
32 | error(function() {
33 | $rootScope.message = 'API Request failed.';
34 | });
35 | };
36 | init();
37 | });
38 |
--------------------------------------------------------------------------------
/api/api.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/go-martini/martini"
5 | "github.com/martini-contrib/cors"
6 | "github.com/martini-contrib/render"
7 | "github.com/martini-contrib/staticbin"
8 | )
9 |
10 | type API struct {
11 | M *martini.ClassicMartini
12 | }
13 |
14 | func NewAPI() *API {
15 | m := martini.Classic()
16 | m.Use(render.Renderer())
17 | m.Use(cors.Allow(&cors.Options{
18 | AllowOrigins: []string{"*"},
19 | AllowMethods: []string{"POST", "GET"},
20 | ExposeHeaders: []string{"Content-Length"},
21 | }))
22 | m.Use(staticbin.Static("web", Asset))
23 | return &API{m}
24 | }
25 |
26 | func (api *API) AddRoutes() {
27 | api.M.Get("/stats", torrentDB.Stats)
28 | api.M.Get("/browse", torrentDB.Categories)
29 | api.M.Get("/browse/:category", torrentDB.Browse)
30 | api.M.Get("/torrent/:btih", torrentDB.Get)
31 |
32 | api.M.Get("/search/:query", torrentDB.Search)
33 | api.M.Get("/search/:query/s/:skip", torrentDB.Search)
34 | api.M.Get("/search/:query/c/:category", torrentDB.Search)
35 | api.M.Get("/search/:query/c/:category/s/:skip", torrentDB.Search)
36 |
37 | api.M.Get("/scrape/:btih", apiScrape)
38 | }
39 |
40 | func (api *API) Run(port string) {
41 | api.M.RunOnAddr(port)
42 | }
43 |
--------------------------------------------------------------------------------
/api/scrape.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/Stephen304/goscrape"
5 | "github.com/go-martini/martini"
6 | "github.com/martini-contrib/render"
7 | "gopkg.in/mgo.v2/bson"
8 | "time"
9 | )
10 |
11 | func scrapeWorker() {
12 | bulk := goscrape.NewBulk(trackers)
13 | for {
14 | stale := torrentDB.GetStale()
15 | if len(stale) > 1 {
16 | results := bulk.ScrapeBulk(stale)
17 | multiUpdate(results)
18 | } else {
19 | time.Sleep(30 * time.Second)
20 | }
21 | time.Sleep(time.Duration(config.ScrapeDelay) * time.Second)
22 | }
23 | }
24 |
25 | func multiUpdate(results []goscrape.Result) {
26 | for _, result := range results {
27 | torrentDB.Update(result.Btih, result.Seeders, result.Leechers)
28 | }
29 | }
30 |
31 | func apiScrape(r render.Render, params martini.Params) {
32 | tresult := Torrent{}
33 | err = torrentDB.collection.Find(bson.M{"_id": params["btih"]}).One(&tresult)
34 | if err != nil {
35 | r.JSON(404, map[string]interface{}{"message": "Torrent not found."})
36 | return
37 | }
38 | result := goscrape.Single(tresult.Details, []string{params["btih"]})[0]
39 | multiUpdate([]goscrape.Result{result})
40 | r.JSON(200, map[string]interface{}{"Swarm": map[string]interface{}{"Seeders": result.Seeders, "Leechers": result.Leechers}, "Lastmod": time.Now()})
41 | }
42 |
--------------------------------------------------------------------------------
/web/app/scripts/controllers/last.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc function
5 | * @name bitCannonApp.controller:BrowseCtrl
6 | * @description
7 | * # BrowseCtrl
8 | * Controller of the bitCannonApp
9 | */
10 | angular.module('bitCannonApp')
11 | .controller('LastCtrl', function ($rootScope, $scope, $http) {
12 | $scope.awesomeThings = [
13 | 'HTML5 Boilerplate',
14 | 'AngularJS',
15 | 'Karma'
16 | ];
17 | $scope.busy = false;
18 | $scope.results = [];
19 | $scope.infinite = function() {
20 | if($scope.busy){return;}
21 | $scope.busy = true;
22 | $http.get($rootScope.api + 'last' + '/s/' + $scope.results.length).
23 | success(function(data, status) {
24 | if (status === 200) {
25 | for (var i = 0; i < data.length; i++) {
26 | var row = data[i];
27 | row.Details = '&tr='+row.Details.join('&tr=');
28 | $scope.results.push(row);
29 | }
30 | if(data.length > 0) {
31 | $scope.busy = false;
32 | }
33 | }
34 | else {
35 | $rootScope.message = data.message;
36 | }
37 | }).
38 | error(function() {
39 | $rootScope.message = 'API Request failed.';
40 | });
41 | };
42 | });
43 |
--------------------------------------------------------------------------------
/api/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "mongo": "mongo",
3 | "bitcannonBindIp": "0.0.0.0",
4 | "bitcannonPort": "1337",
5 | "scrapeEnabled": true,
6 | "scrapeDelay": 0,
7 | "trackers": [
8 | "udp://tracker.coppersurfer.tk:6969/announce",
9 | "udp://tracker.leechers-paradise.org:6969/announce",
10 | "udp://tracker.zer0day.to:1337/announce",
11 | "http://tracker.opentrackr.org:1337/announce",
12 | "udp://tracker.opentrackr.org:1337/announce",
13 | "udp://p4p.arenabg.com:1337/announce",
14 | "http://p4p.arenabg.com:1337/announce",
15 | "udp://9.rarbg.com:2710/announce",
16 | "http://explodie.org:6969/announce",
17 | "udp://explodie.org:6969/announce",
18 | "udp://public.popcorn-tracker.org:6969/announce",
19 | "udp://tracker.internetwarriors.net:1337/announce",
20 | "http://tracker.dler.org:6969/announce",
21 | "http://tracker1.wasabii.com.tw:6969/announce",
22 | "http://tracker.mg64.net:6881/announce",
23 | "http://mgtracker.org:6969/announce",
24 | "udp://tracker.mg64.net:6969/announce",
25 | "udp://mgtracker.org:2710/announce",
26 | "http://tracker2.wasabii.com.tw:6969/announce",
27 | "http://tracker.tiny-vps.com:6969/announce"
28 | ],
29 | "blacklisted_categories": [
30 | "Category to blacklist 1",
31 | "Category to blacklist 2"
32 | ],
33 | "archives": []
34 | }
35 |
--------------------------------------------------------------------------------
/web/app/styles/main.css:
--------------------------------------------------------------------------------
1 | /* Push content to start at the bottom of the navbar */
2 | body {
3 | padding-top: 60px;
4 | }
5 |
6 | /* Ensures that the brand button clickable area is full height */
7 | .navbar-brand {
8 | height: 60px;
9 | }
10 |
11 | .alert {
12 | margin-top: 20px;
13 | }
14 |
15 | /* Remove dotted outline on focused elements */
16 | a:focus, a:active,
17 | button::-moz-focus-inner,
18 | input[type="reset"]::-moz-focus-inner,
19 | input[type="button"]::-moz-focus-inner,
20 | input[type="submit"]::-moz-focus-inner,
21 | select::-moz-focus-inner,
22 | input[type="file"] > input[type="button"]::-moz-focus-inner {
23 | border: 0;
24 | outline : 0;
25 | }
26 |
27 | /* Slide down transition animations */
28 | .animate-slide-container {
29 | position:relative;
30 | height:43px;
31 | overflow:hidden;
32 | }
33 | .animate-slide {
34 | padding:10px;
35 | }
36 | .animate-slide.ng-animate {
37 | -webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s;
38 | transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s;
39 | position:absolute;
40 | top:0;
41 | left:0;
42 | right:0;
43 | bottom:0;
44 | }
45 | .animate-slide.ng-enter {
46 | top:-50px;
47 | }
48 | .animate-slide.ng-leave.ng-leave-active {
49 | top:50px;
50 | }
51 | .animate-slide.ng-leave,
52 | .animate-slide.ng-enter.ng-enter-active {
53 | top:0;
54 | }
55 |
--------------------------------------------------------------------------------
/web/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bitcannon",
3 | "version": "0.0.0",
4 | "dependencies": {
5 | "express": "~4.14.0"
6 | },
7 | "devDependencies": {
8 | "grunt": "~0.4.5",
9 | "grunt-autoprefixer": "~0.7.3",
10 | "grunt-concurrent": "~0.5.0",
11 | "grunt-contrib-clean": "~0.5.0",
12 | "grunt-contrib-concat": "~0.4.0",
13 | "grunt-contrib-connect": "~0.7.1",
14 | "grunt-contrib-copy": "~0.5.0",
15 | "grunt-contrib-cssmin": "~0.9.0",
16 | "grunt-contrib-htmlmin": "~0.3.0",
17 | "grunt-contrib-imagemin": "~0.8.1",
18 | "grunt-contrib-jshint": "~0.10.0",
19 | "grunt-contrib-uglify": "~0.4.0",
20 | "grunt-contrib-watch": "~0.6.1",
21 | "grunt-filerev": "~0.2.1",
22 | "grunt-google-cdn": "~0.4.0",
23 | "grunt-karma": "~0.9.0",
24 | "grunt-newer": "~0.7.0",
25 | "grunt-ng-annotate": "~0.9.2",
26 | "grunt-svgmin": "~0.4.0",
27 | "grunt-usemin": "~2.1.1",
28 | "grunt-wiredep": "~1.7.0",
29 | "jasmine-core": "~2.1.3",
30 | "jshint-stylish": "~0.2.0",
31 | "karma": "~0.12.28",
32 | "karma-jasmine": "~0.3.2",
33 | "karma-phantomjs-launcher": "~0.1.4",
34 | "load-grunt-tasks": "~0.4.0",
35 | "time-grunt": "~0.3.1"
36 | },
37 | "engines": {
38 | "node": ">=0.10.0"
39 | },
40 | "scripts": {
41 | "test": "grunt test",
42 | "start": "node --harmony index.js"
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/web/app/views/last.html:
--------------------------------------------------------------------------------
1 |