Browse Source

Add readme, license, torrent search and download code test, move old web to a subfolder

master
Arti Zirk 5 years ago
parent
commit
fea3a714f0
  1. 5
      .gitignore
  2. 7
      LICENSE
  3. 4
      README.md
  4. 94
      examples/transmission.py
  5. 8
      requirements.txt
  6. 0
      web/metainfo-dl.py
  7. 0
      web/static/css/bootstrap-theme.css
  8. 0
      web/static/css/bootstrap-theme.css.map
  9. 0
      web/static/css/bootstrap-theme.min.css
  10. 0
      web/static/css/bootstrap.css
  11. 0
      web/static/css/bootstrap.css.map
  12. 0
      web/static/css/bootstrap.min.css
  13. 0
      web/static/css/style.css
  14. 0
      web/static/fonts/glyphicons-halflings-regular.eot
  15. 0
      web/static/fonts/glyphicons-halflings-regular.svg
  16. 0
      web/static/fonts/glyphicons-halflings-regular.ttf
  17. 0
      web/static/fonts/glyphicons-halflings-regular.woff
  18. 0
      web/static/js/bootstrap.js
  19. 0
      web/static/js/bootstrap.min.js
  20. 0
      web/static/js/jquery.min.js
  21. 0
      web/static/js/npm.js
  22. 0
      web/templates/downloads.html
  23. 0
      web/templates/layout.html
  24. 0
      web/templates/movies.html
  25. 0
      web/templates/movies_info.html
  26. 0
      web/templates/series.html
  27. 0
      web/update-dirs.py
  28. 0
      web/uwsgi.ini
  29. 0
      web/web-interface.py
  30. 0
      web/web_interface.py
  31. 0
      web/wsgi.py

5
.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/

7
LICENSE

@ -0,0 +1,7 @@
Copyright 2016 Arti Zirk <arti.zirk@gmail.com>
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.

4
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

94
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)

8
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

0
metainfo-dl.py → web/metainfo-dl.py

0
static/css/bootstrap-theme.css → web/static/css/bootstrap-theme.css

0
static/css/bootstrap-theme.css.map → web/static/css/bootstrap-theme.css.map

0
static/css/bootstrap-theme.min.css → web/static/css/bootstrap-theme.min.css

0
static/css/bootstrap.css → web/static/css/bootstrap.css

0
static/css/bootstrap.css.map → web/static/css/bootstrap.css.map

0
static/css/bootstrap.min.css → web/static/css/bootstrap.min.css

0
static/css/style.css → web/static/css/style.css

0
static/fonts/glyphicons-halflings-regular.eot → web/static/fonts/glyphicons-halflings-regular.eot

0
static/fonts/glyphicons-halflings-regular.svg → web/static/fonts/glyphicons-halflings-regular.svg

0
static/fonts/glyphicons-halflings-regular.ttf → web/static/fonts/glyphicons-halflings-regular.ttf

0
static/fonts/glyphicons-halflings-regular.woff → web/static/fonts/glyphicons-halflings-regular.woff

0
static/js/bootstrap.js → web/static/js/bootstrap.js

0
static/js/bootstrap.min.js → web/static/js/bootstrap.min.js

0
static/js/jquery.min.js → web/static/js/jquery.min.js

0
static/js/npm.js → web/static/js/npm.js

0
templates/downloads.html → web/templates/downloads.html

0
templates/layout.html → web/templates/layout.html

0
templates/movies.html → web/templates/movies.html

0
templates/movies_info.html → web/templates/movies_info.html

0
templates/series.html → web/templates/series.html

0
update-dirs.py → web/update-dirs.py

0
uwsgi.ini → web/uwsgi.ini

0
web-interface.py → web/web-interface.py

0
web_interface.py → web/web_interface.py

0
wsgi.py → web/wsgi.py

Loading…
Cancel
Save