Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ffad6b7
test update
DiMartinoXBMC Dec 18, 2015
942a55a
test update #2
DiMartinoXBMC Dec 18, 2015
b403371
test update #3
DiMartinoXBMC Dec 18, 2015
90e5948
beta
DiMartinoXBMC Dec 18, 2015
68409a4
beta
DiMartinoXBMC Dec 18, 2015
bf5de38
beta fix
DiMartinoXBMC Dec 18, 2015
d39d77a
rpi (armv6) bin add
DiMartinoXBMC Dec 19, 2015
7985cab
rpi (armv6) bin add info
DiMartinoXBMC Dec 19, 2015
3495306
android exec fix
DiMartinoXBMC Dec 21, 2015
4f1c8ee
android exec fix
DiMartinoXBMC Dec 21, 2015
91b1034
meme fix
DiMartinoXBMC Jan 16, 2016
35f474b
Fix process leak
Jan 28, 2016
c79c33c
Merge pull request #1 from Palatosino/patch-1
DiMartinoXBMC Jan 29, 2016
27347f7
aarch64 by srg70
DiMartinoXBMC Dec 20, 2016
fdac538
aarch64 fix by vkravets
DiMartinoXBMC Dec 22, 2016
1ff3f6d
wtf
DiMartinoXBMC Dec 22, 2016
661fb1a
Add remote support. Client/server connection.
Jan 3, 2017
3cb45a0
+gitattributes
Jan 3, 2017
fb61242
Bump V0.1.5.1~vd
Jan 3, 2017
1f0f8b4
Add missing + default values
Jan 4, 2017
b8640e9
Bump V0.1.5.2~vd
Jan 4, 2017
db39c43
fix
Jan 5, 2017
c6eed23
Bump V0.1.5.3~vd
Jan 5, 2017
1479e3a
fix
Jan 5, 2017
1c08a3e
+standalone ver
Jan 5, 2017
9fabbd9
Bump V0.1.5.4~vd
Jan 5, 2017
af54c50
Client\server mode, remote execution, standalone version by -=Vd=-
DiMartinoXBMC Jan 6, 2017
8d91949
Merge remote-tracking branch 'DiMartino/master'
Jan 10, 2017
b6cb463
Merge pull request #2 from vadyur/master
DiMartinoXBMC Jan 10, 2017
f66555a
stat
Jan 13, 2017
931a61c
Show torrent statistic
Jan 18, 2017
f23533a
Bump V0.2.1
Jan 18, 2017
31a4cf3
Merge pull request #3 from vadyur/master
DiMartinoXBMC Jan 19, 2017
2c29235
WebUI (http://<host>:<port>/stat) by -=Vd=-
DiMartinoXBMC Jan 19, 2017
626f745
Show torrent statistic - fix
Jan 25, 2017
71d3ddc
Bump V0.2.2
Jan 25, 2017
1c0297e
Handling CTRL+C in standalone mode
Jan 31, 2017
c6017c6
Bump V0.2.3
Jan 31, 2017
f0dfcf8
fix 100% load proccess
Jan 31, 2017
150b7a7
Bump V0.2.4
Jan 31, 2017
a0c66da
Fixes
Feb 9, 2017
647c068
Bump V0.2.5
Feb 9, 2017
2c8993a
Merge pull request #4 from vadyur/master
DiMartinoXBMC Feb 9, 2017
2d33407
import fix for SpectreKr
Feb 10, 2017
6155fd7
Bump V0.2.5.1
Feb 10, 2017
e2ff566
No 'requests' module needs for server mode.
Feb 10, 2017
95f6fbc
Bump V0.2.5.2
Feb 10, 2017
4216bad
android fix
DiMartinoXBMC Feb 14, 2017
1bd1535
Merge remote-tracking branch 'DiMartino/master'
Feb 17, 2017
b2b5410
Bump V0.2.5.2a
Feb 17, 2017
5583d6d
Always use 32 bit binary on Windows
Mar 11, 2017
2b8e0e1
Always use 32 bit binary on Windows #2
Mar 11, 2017
627c512
Bump V0.2.6
Mar 13, 2017
321d222
Merge pull request #5 from vadyur/master
DiMartinoXBMC Mar 19, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*_test.py export-ignore
*.pyo export-ignore
.idea/ export-ignore
*.sln export-ignore
*.pyproj export-ignore
*.suo export-ignore
*.zip export-ignore
*.exe export-ignore
.gitattributes export-ignore
.gitignore export-ignore
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea/
*.py[cod]
bin/
*.pyproj
*.suo
*.exe
7 changes: 6 additions & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.module.torrent2http" name="torrent2http" version="0.1.0" provider-name="anteo">
<addon id="script.module.torrent2http" name="torrent2http" version="0.2.6" provider-name="anteo,DiMartino,-=Vd=-">
<requires>
<import addon="xbmc.python" version="2.14.0"/>
<import addon="script.module.requests" optional="false"/>
</requires>
<extension point="xbmc.python.module" library="lib"/>
<extension point="xbmc.python.script" library="main.py">
<provides>executable</provides>
</extension>
<extension point="xbmc.service" library="service.py" start="startup" />
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<language>en</language>
Expand Down
1 change: 1 addition & 0 deletions bin/android_arm/torrent2http.size.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
30366960
Binary file added bin/android_arm/torrent2http.zip
Binary file not shown.
1 change: 1 addition & 0 deletions bin/darwin_x64/torrent2http.size.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
26146540
Binary file added bin/darwin_x64/torrent2http.zip
Binary file not shown.
1 change: 1 addition & 0 deletions bin/linux_aarch64/torrent2http.size.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
25809824
Binary file added bin/linux_aarch64/torrent2http.zip
Binary file not shown.
1 change: 1 addition & 0 deletions bin/linux_arm/torrent2http.size.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24466041
Binary file added bin/linux_arm/torrent2http.zip
Binary file not shown.
1 change: 1 addition & 0 deletions bin/linux_armv6/torrent2http.size.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24522477
Binary file added bin/linux_armv6/torrent2http.zip
Binary file not shown.
1 change: 1 addition & 0 deletions bin/linux_x64/torrent2http.size.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
29381937
Binary file added bin/linux_x64/torrent2http.zip
Binary file not shown.
1 change: 1 addition & 0 deletions bin/linux_x86/torrent2http.size.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
25228652
Binary file added bin/linux_x86/torrent2http.zip
Binary file not shown.
63 changes: 63 additions & 0 deletions bin/public.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#-*- coding: utf-8 -*-
'''
Torrenter v2 plugin for XBMC/Kodi
Copyright (C) 2015 srg70, RussakHH, DiMartino
'''

import os

def get_libname(platform):
return ["torrent2http" + (".exe" if 'windows' in platform else "")]

class Public:
def __init__( self ):
self.platforms=[]
self.root=os.path.dirname(__file__)
for dir in os.listdir(self.root):
if os.path.isdir(os.path.join(self.root,dir)):
self.platforms.append(dir)
self._generate_size_file()

def _generate_size_file( self ):
for platform in self.platforms:
for libname in get_libname(platform):
self.libname=libname
self.platform=platform
self.libdir = os.path.join(self.root, self.platform)
self.libpath = os.path.join(self.libdir, self.libname)
self.sizepath=self.libpath+'.size.txt'
self.zipname=self.libname+'.zip'
zippath=os.path.join(self.libdir, self.zipname)
system=platform+'/'
if os.path.exists(self.libpath):
if not os.path.exists(self.sizepath):
print system+self.libname+' NO SIZE'
self._makezip()
elif not os.path.exists(zippath):
print system+self.libname+' NO ZIP'
self._makezip()
else:
size=str(os.path.getsize(self.libpath))
size_old=open( self.sizepath, "r" ).read()
if size_old!=size:
print system+self.libname+' NOT EQUAL'
self._makezip()
else:
print system+self.libname+' NO ACTION'
else:
print system+self.libname+' NO LIB'

def _makezip(self):
open( self.sizepath, "w" ).write( str(os.path.getsize(self.libpath)) )
os.chdir(self.libdir)
os.system('del %s' % (self.zipname))
os.system('"C:\\Program Files\\7-Zip\\7z.exe" a %s.zip %s' %
(self.libname, self.libname))
os.chdir(self.root)
#os.system('"C:\\Program Files\\7-Zip\\7z.exe" a %s.zip %s' %
# (self.platform['system']+os.sep+self.libname, self.platform['system']+os.sep+self.libname))

if ( __name__ == "__main__" ):
# start
#TODO: publicate
Public()
1 change: 1 addition & 0 deletions bin/windows_x86/torrent2http.exe.size.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22362887
Binary file added bin/windows_x86/torrent2http.exe.zip
Binary file not shown.
18 changes: 18 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
[B]Version 0.2.1[/B]
+ WebUI (http://<host>:<port>/stat) by -=Vd=-

[B]Version 0.2.0[/B]
+ Client\server mode, remote execution, standalone version by -=Vd=-

[B]Version 0.1.4[/B]
+ Unix ARM x64 (aarch64) by srg70

[B]Version 0.1.3[/B]
+ Android execute fix

[B]Version 0.1.2[/B]
+ Torrent2http binaries for Raspberry Pi v1 (arm v6)

[B]Version 0.1.1[/B]
+ Automatic download manager for binaries

[B]Version 0.1.0[/B]
+ Torrent2http binaries updated to 1.0.5
+ Added Android Lollipop 5/Marshmallow 6 ARM support
Expand Down
Empty file added lib/__init__.py
Empty file.
13 changes: 12 additions & 1 deletion lib/torrent2http/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ class Encryption:
PeerInfo = namedtuple('PeerInfo', "ip, flags, source, up_speed, down_speed, total_upload, total_download, "
"country, client")

from engine import Engine
from remote.remotesettings import *

s = Settings()

try:
if s.role == 'client':
from remote.remoteengine import ClientEngine as Engine
else:
from engine import Engine
except:
from engine import Engine

from platform import Platform
from error import Error
65 changes: 65 additions & 0 deletions lib/torrent2http/download.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#import sys
import os
import xbmc, xbmcgui, xbmcvfs, xbmcaddon
from net import HTTP

__libbaseurl__ = "https://github.com/DiMartinoXBMC/script.module.torrent2http/raw/master/bin"
__settings__ = xbmcaddon.Addon(id='script.module.torrent2http')
__version__ = __settings__.getAddonInfo('version')
__plugin__ = __settings__.getAddonInfo('name') + " v." + __version__

def get_libname(platform):
return ["torrent2http" + (".exe" if 'windows' in platform else "")]

def log(msg):
try:
xbmc.log("### [%s]: %s" % (__plugin__,msg,), level=xbmc.LOGNOTICE )
except UnicodeEncodeError:
xbmc.log("### [%s]: %s" % (__plugin__,msg.encode("utf-8", "ignore"),), level=xbmc.LOGNOTICE )
except:
xbmc.log("### [%s]: %s" % (__plugin__,'ERROR LOG',), level=xbmc.LOGNOTICE )

def getSettingAsBool(setting):
return __settings__.getSetting(setting).lower() == "true"

class LibraryManager():
def __init__(self, dest_path, platform):
self.dest_path = dest_path
self.platform = platform

def check_update(self):
need_update=False
if __settings__.getSetting('plugin_name')!=__plugin__:
__settings__.setSetting('plugin_name', __plugin__)
for libname in get_libname(self.platform):
self.libpath = os.path.join(self.dest_path, libname)
self.sizepath=os.path.join(self.dest_path, libname+'.size.txt')
size=str(os.path.getsize(self.libpath))
size_old=open( self.sizepath, "r" ).read()
if size_old!=size:
need_update=True
return need_update

def update(self):
if self.check_update():
for libname in get_libname(self.platform):
self.libpath = os.path.join(self.dest_path, libname)
xbmcvfs.delete(self.libpath)
self.download()

def download(self):
xbmcvfs.mkdirs(self.dest_path)
for libname in get_libname(self.platform):
dest = os.path.join(self.dest_path, libname)
log("try to fetch %s" % libname)
url = "%s/%s/%s.zip" % (__libbaseurl__, self.platform, libname)
try:
self.http = HTTP()
self.http.fetch(url, download=dest + ".zip", progress=True)
log("%s -> %s" % (url, dest))
xbmc.executebuiltin('XBMC.Extract("%s.zip","%s")' % (dest, self.dest_path), True)
xbmcvfs.delete(dest + ".zip")
except:
text = 'Failed download %s!' % libname
xbmc.executebuiltin("XBMC.Notification(%s,%s,%s)" % (__plugin__,text,750))
return True
28 changes: 23 additions & 5 deletions lib/torrent2http/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import urllib2
import httplib
from os.path import dirname
from download import LibraryManager

import logpipe
import mimetypes
Expand All @@ -29,8 +30,12 @@ class Engine:
def _ensure_binary_executable(self, path):
st = os.stat(path)
if not st.st_mode & stat.S_IEXEC:
self._log("%s is not executable, trying to change its mode..." % path)
os.chmod(path, st.st_mode | stat.S_IEXEC)
try:
self._log("%s is not executable, trying to change its mode..." % path)
os.chmod(path, st.st_mode | stat.S_IEXEC)
except Exception, e:
self._log("Failed! Exception: %s" % str(e))
return False
st = os.stat(path)
if st.st_mode & stat.S_IEXEC:
self._log("Succeeded")
Expand All @@ -53,12 +58,24 @@ def _get_binary_path(self, binaries_path):
:param binaries_path:
:return: torrent2http binary path
"""

arch = self.platform.arch
# Always use 32 bit binary on Windows
if self.platform.system == 'windows':
arch = arch.replace('x64', 'x86')

binary = "torrent2http" + (".exe" if self.platform.system == 'windows' else "")
binary_dir = os.path.join(binaries_path, "%s_%s" % (self.platform.system, self.platform.arch))
binary_dir = os.path.join(binaries_path, "%s_%s" % (self.platform.system, arch))

binary_path = os.path.join(binary_dir, binary)
lm=LibraryManager(binary_dir, "%s_%s" % (self.platform.system, arch))
if not os.path.isfile(binary_path):
raise Error("Can't find torrent2http binary for %s" % self.platform,
Error.UNKNOWN_PLATFORM, platform=str(self.platform))
success=lm.download()
if not success:
raise Error("Can't find torrent2http or download binary for %s" % self.platform,
Error.UNKNOWN_PLATFORM, platform=str(self.platform))
#This is needed only if bin in folder that not deletes on update!
#else: lm.update()

if not self._ensure_binary_executable(binary_path):
if self.platform.system == "android":
Expand Down Expand Up @@ -472,6 +489,7 @@ def close(self):
else:
self._log("torrent2http successfully shut down.")
self.wait_on_close_timeout = None
self.process.wait()
self.started = False
self.logpipe = None
self.process = None
2 changes: 1 addition & 1 deletion lib/torrent2http/mimetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def enum_types(mimedb):
except EnvironmentError:
break
try:
ctype = ctype.encode(default_encoding) # omit in 3.x!
ctype = ctype#.encode(default_encoding) # omit in 3.x!
except UnicodeEncodeError:
pass
else:
Expand Down
Loading