-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a shameless ripoff of Trakt TV's DB code...but it works!!
- Loading branch information
Showing
2,592 changed files
with
455,466 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
*.idea/* | ||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
# Windows | ||
# ========================= | ||
|
||
# Windows image file caches | ||
Thumbs.db | ||
ehthumbs.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk | ||
.idea/* | ||
.idea/workspace.xml | ||
.idea/misc.xml | ||
.idea/modules.xml | ||
Tester.py | ||
.idea/RequestChannel.bundle.iml | ||
.idea/vcs.xml | ||
.idea/FlexTV.bundle.iml | ||
.idea/vcs.xml | ||
.idea/vcs.xml | ||
Contents/PlexFiles/bootstrap.py | ||
Contents/PlexFiles/config.py | ||
!/Contents/Libraries/Shared/subzero/lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
""" | ||
This is a custom Object Class that we can use to emulate the XML structure of Plex's API output | ||
For each container type you want to create, specify self.name, and an optional list of | ||
accpetable attributes. | ||
""" | ||
import datetime | ||
|
||
ObjectClass = getattr(getattr(Redirect, "_object_class"), "__bases__")[0] | ||
|
||
|
||
class CustomContainer(ObjectClass): | ||
|
||
def __init__(self, attributes=None, children=None): | ||
ObjectClass.__init__(self, "") | ||
self.children = children | ||
self.attributes = attributes | ||
self.SetHeader("Content-Type", "application/xml") | ||
self.items = [] | ||
|
||
def Content(self): | ||
xml = self.to_xml() | ||
return xml | ||
|
||
def add(self, obj): | ||
if self.children is None: | ||
self.items.append(obj) | ||
else: | ||
append = False | ||
for child in self.children: | ||
if obj.name == child: | ||
append = True | ||
|
||
if append is True: | ||
self.items.append(obj) | ||
else: | ||
Log.Error("Child type %s is not allowed" % obj.name) | ||
|
||
def to_xml(self): | ||
string = "" | ||
string += ('<' + self.name) | ||
|
||
if self.show_size is True: | ||
size = str(len(self.items)) | ||
string += (' size="' + size + '"') | ||
|
||
if self.dict is not None: | ||
for key, value in self.dict.items(): | ||
allowed = True | ||
if self.attributes is not None: | ||
allowed = False | ||
for attribute in self.attributes: | ||
if key == attribute: | ||
allowed = True | ||
|
||
if allowed is True: | ||
value = str(value) | ||
value = value.replace("&", "&") | ||
value = value.replace("<", "<") | ||
value = value.replace(">", ">") | ||
value = value.replace("\"", """) | ||
string += (" " + key + '="' + value + '"') | ||
else: | ||
Log.Error("Attribute " + key + " is not allowed in this container.") | ||
|
||
count = len(self.items) | ||
if count >= 1: | ||
string += '>\n' | ||
for obj in self.items: | ||
string += obj.to_xml() | ||
|
||
string += '</' + self.name + '>' | ||
|
||
else: | ||
string += '/>\n' | ||
|
||
return string | ||
|
||
|
||
# Class to emulate proper Plex media container | ||
# TODO: Auto grab version number from init | ||
class MediaContainer(CustomContainer): | ||
def __init__(self, dict=None): | ||
self.show_size = True | ||
self.dict = dict | ||
self.name = "MediaContainer" | ||
CustomContainer.__init__(self) | ||
|
||
|
||
# Class to emulate proper Plex media container | ||
class MetaContainer(CustomContainer): | ||
def __init__(self, dict=None): | ||
self.show_size = True | ||
self.dict = dict | ||
self.name = "MetaData" | ||
CustomContainer.__init__(self) | ||
|
||
|
||
# Class to emulate proper Plex device container | ||
class StatContainer(CustomContainer): | ||
def __init__(self, dict=None): | ||
self.show_size = False | ||
self.dict = dict | ||
self.name = "Tag" | ||
allowed_attributes = [ | ||
"tag", | ||
"tag_type", | ||
"tag_count", | ||
"title", | ||
"count", | ||
"tags" | ||
] | ||
|
||
allowed_children = [ | ||
"Connection" | ||
] | ||
|
||
CustomContainer.__init__(self, allowed_attributes, allowed_children) | ||
|
||
|
||
class CastContainer(CustomContainer): | ||
def __init__(self, dict=None): | ||
self.show_size = False | ||
self.dict = dict | ||
self.name = "Device" | ||
CustomContainer.__init__(self) | ||
|
||
|
||
class StatusContainer(CustomContainer): | ||
def __init__(self, dict=None): | ||
self.show_size = False | ||
self.dict = dict | ||
self.name = "Status" | ||
CustomContainer.__init__(self) | ||
|
||
|
||
class ZipObject(ObjectClass): | ||
def __init__(self, data): | ||
ObjectClass.__init__(self, "") | ||
self.zipdata = data | ||
self.SetHeader("Content-Type", "application/zip") | ||
|
||
def Content(self): | ||
self.SetHeader("Content-Disposition", | ||
'attachment; filename="' + datetime.datetime.now().strftime("Logs_%y%m%d_%H-%M-%S.zip") | ||
+ '"') | ||
return self.zipdata |
Oops, something went wrong.