diff --git a/.gitignore b/.gitignore index f5dd7da..c7262c3 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ lib64/ parts/ sdist/ var/ +wheels/ *.egg-info/ .installed.cfg *.egg @@ -89,5 +90,5 @@ ENV/ # Rope project settings .ropeproject -static/Filmid/ -static/filmid/ +web/static/Filmid/ +web/static/filmid/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fc7aab6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright 2016 Arti Zirk + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3f77232 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# Karu media server + +Karu media server is a collection of python programs for managing your movie and +tv show collections diff --git a/examples/transmission.py b/examples/transmission.py new file mode 100644 index 0000000..dbe7ad3 --- /dev/null +++ b/examples/transmission.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python3 +from base64 import b64decode +from pprint import pprint +from urllib.parse import urlencode, quote +from requests import get +import transmissionrpc +from imdbpie import Imdb +import time +import feedparser +import PTN +import sys + + +extratorrents = "http://extra.to" + +default_trackers = [ + 'udp://glotorrents.pw:6969/announce', + 'udp://tracker.openbittorrent.com:80', + 'udp://tracker.coppersurfer.tk:6969', + 'udp://tracker.leechers-paradise.org:6969', + 'udp://p4p.arenabg.ch:1337', + 'udp://tracker.internetwarriors.net:1337', + 'udp://tracker.opentrackr.org:1337/announce' +] + +r = get("https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt") + +best_trackers = r.text + +for tracker in best_trackers.split("\n"): + tracker = tracker.strip() + if tracker: + default_trackers.append(tracker) + +def hash_to_magnet(infoHash, name=None, trackers=None): + try: + b64decode(infoHash) + except: + raise Exception("Invalid infoHash") + magnet = { + "dn": name, + "tr": list(default_trackers) + } + if not name: + del magnet["dn"] + if trackers: + magnet["tr"].extend(trackers) + return "magnet:?xt=urn:btih:{}&".format(infoHash) + urlencode(magnet, doseq=True) + + + +def search_extra(query_term): + query_term = quote(query_term + " ettv") + url = f"{extratorrents}/rss.xml?type=search&search={query_term}" + entries = feedparser.parse(url)["entries"] + for e in entries: + info = { + "infoHash": e["info_hash"], + "raw_title": e["title"], + "seeders": e["seeders"], + "leechers": e["leechers"], + "size": e["size"] + } + info.update(PTN.parse(e["title"])) + yield info + + +magnet = hash_to_magnet("6a02592d2bbc069628cd5ed8a54f88ee06ac0ba5", + trackers=( + "http://bt1.archive.org:6969/announce", + "http://bt2.archive.org:6969/announce" + ) + ) + + +search = "the flash s03e02" +search = sys.argv[1] +#pprint(list(search_extra(search))) +best = sorted(search_extra(search), key=lambda e: e["seeders"])[0] +pprint(best) + +magnet = hash_to_magnet(best["infoHash"], + name=search) + +tc = transmissionrpc.Client("localhost") +t = tc.add_torrent(magnet) +hashString = t.hashString +while True: + t = tc.get_torrent(hashString) + print(t.name, t.status, t.metadataPercentComplete*100, t.percentDone*100) + if t.metadataPercentComplete == 1: + pprint(t.files()) + exit(0) + time.sleep(1) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..28e308b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +CacheControl==0.11.7 +feedparser==5.2.1 +imdbpie==4.2.0 +lockfile==0.12.2 +parse-torrent-name==1.1.1 +requests==2.12.4 +six==1.10.0 +transmissionrpc==0.11 diff --git a/metainfo-dl.py b/web/metainfo-dl.py similarity index 100% rename from metainfo-dl.py rename to web/metainfo-dl.py diff --git a/static/css/bootstrap-theme.css b/web/static/css/bootstrap-theme.css similarity index 100% rename from static/css/bootstrap-theme.css rename to web/static/css/bootstrap-theme.css diff --git a/static/css/bootstrap-theme.css.map b/web/static/css/bootstrap-theme.css.map similarity index 100% rename from static/css/bootstrap-theme.css.map rename to web/static/css/bootstrap-theme.css.map diff --git a/static/css/bootstrap-theme.min.css b/web/static/css/bootstrap-theme.min.css similarity index 100% rename from static/css/bootstrap-theme.min.css rename to web/static/css/bootstrap-theme.min.css diff --git a/static/css/bootstrap.css b/web/static/css/bootstrap.css similarity index 100% rename from static/css/bootstrap.css rename to web/static/css/bootstrap.css diff --git a/static/css/bootstrap.css.map b/web/static/css/bootstrap.css.map similarity index 100% rename from static/css/bootstrap.css.map rename to web/static/css/bootstrap.css.map diff --git a/static/css/bootstrap.min.css b/web/static/css/bootstrap.min.css similarity index 100% rename from static/css/bootstrap.min.css rename to web/static/css/bootstrap.min.css diff --git a/static/css/style.css b/web/static/css/style.css similarity index 100% rename from static/css/style.css rename to web/static/css/style.css diff --git a/static/fonts/glyphicons-halflings-regular.eot b/web/static/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from static/fonts/glyphicons-halflings-regular.eot rename to web/static/fonts/glyphicons-halflings-regular.eot diff --git a/static/fonts/glyphicons-halflings-regular.svg b/web/static/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from static/fonts/glyphicons-halflings-regular.svg rename to web/static/fonts/glyphicons-halflings-regular.svg diff --git a/static/fonts/glyphicons-halflings-regular.ttf b/web/static/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from static/fonts/glyphicons-halflings-regular.ttf rename to web/static/fonts/glyphicons-halflings-regular.ttf diff --git a/static/fonts/glyphicons-halflings-regular.woff b/web/static/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from static/fonts/glyphicons-halflings-regular.woff rename to web/static/fonts/glyphicons-halflings-regular.woff diff --git a/static/js/bootstrap.js b/web/static/js/bootstrap.js similarity index 100% rename from static/js/bootstrap.js rename to web/static/js/bootstrap.js diff --git a/static/js/bootstrap.min.js b/web/static/js/bootstrap.min.js similarity index 100% rename from static/js/bootstrap.min.js rename to web/static/js/bootstrap.min.js diff --git a/static/js/jquery.min.js b/web/static/js/jquery.min.js similarity index 100% rename from static/js/jquery.min.js rename to web/static/js/jquery.min.js diff --git a/static/js/npm.js b/web/static/js/npm.js similarity index 100% rename from static/js/npm.js rename to web/static/js/npm.js diff --git a/templates/downloads.html b/web/templates/downloads.html similarity index 100% rename from templates/downloads.html rename to web/templates/downloads.html diff --git a/templates/layout.html b/web/templates/layout.html similarity index 100% rename from templates/layout.html rename to web/templates/layout.html diff --git a/templates/movies.html b/web/templates/movies.html similarity index 100% rename from templates/movies.html rename to web/templates/movies.html diff --git a/templates/movies_info.html b/web/templates/movies_info.html similarity index 100% rename from templates/movies_info.html rename to web/templates/movies_info.html diff --git a/templates/series.html b/web/templates/series.html similarity index 100% rename from templates/series.html rename to web/templates/series.html diff --git a/update-dirs.py b/web/update-dirs.py similarity index 100% rename from update-dirs.py rename to web/update-dirs.py diff --git a/uwsgi.ini b/web/uwsgi.ini similarity index 100% rename from uwsgi.ini rename to web/uwsgi.ini diff --git a/web-interface.py b/web/web-interface.py similarity index 100% rename from web-interface.py rename to web/web-interface.py diff --git a/web_interface.py b/web/web_interface.py similarity index 100% rename from web_interface.py rename to web/web_interface.py diff --git a/wsgi.py b/web/wsgi.py similarity index 100% rename from wsgi.py rename to web/wsgi.py