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

This commit is contained in:
Arti Zirk 2017-01-09 07:52:38 +02:00
parent 58ad3f729c
commit fea3a714f0
31 changed files with 116 additions and 2 deletions

5
.gitignore vendored
View File

@ -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 Normal file
View File

@ -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 Normal file
View File

@ -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 Normal file
View File

@ -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 Normal file
View File

@ -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

View File

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB