Done with most of the requests of movies and started most of the dyn loading of elements

This commit is contained in:
2017-02-09 00:41:15 +01:00
parent e7f806655d
commit 9e64a2d53a
11 changed files with 194 additions and 32 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -3,7 +3,7 @@
# @Author: KevinMidboe
# @Date: 2017-02-08 14:00:04
# @Last Modified by: KevinMidboe
# @Last Modified time: 2017-02-08 14:06:48
# @Last Modified time: 2017-02-08 22:50:17
from requests import get
@@ -66,4 +66,8 @@ def plexSearch(query):
if __name__ == "__main__":
print(plexSearch("star+wars"))
# print(plexSearch("star+wars"))
tiss = plexSearch("star+wars")
for al in tiss:
if (al['year']==2015):
print('thishsihis')

View File

@@ -3,11 +3,25 @@
# @Author: KevinMidboe
# @Date: 2017-01-28 23:21:22
# @Last Modified by: KevinMidboe
# @Last Modified time: 2017-01-28 23:35:04
# @Last Modified time: 2017-02-08 20:29:53
from os import system, popen
import xml.etree.ElementTree as ET
from unicodedata import normalize
from requests import get
plexBaseURL = "http://10.0.0.41:32400/"
def parsePlexWatching(obj):
print(obj)
def getPlexWatching():
requestType = "status/sessions"
header = {'Accept': 'application/json'}
url = plexBaseURL + requestType
response = get(url, headers=header)
if response.status_code == 200:
watchingObj = response.json()
res = parsePlexWatching(watchingObj)
def plex_watching():
# Every call saves the info of session.xml to a file named plexPlaying
@@ -53,4 +67,4 @@ def plex_watching():
return 'Null playing'
if __name__ == '__main__':
print(plex_watching())
print(getPlexWatching())

View File

@@ -0,0 +1,13 @@
{
'_children': [{'type': 'episode', 'viewOffset': '504654', 'grandparentThumb': '/library/metadata/4994/thumb/1486551832', 'chapterSource': '', 'grandparentArt': '/library/metadata/4994/art/1486551832', 'updatedAt': '1486581424', 'sessionKey': '177', 'parentThumb': '/library/metadata/17543/thumb/1486551832', 'key': '/library/metadata/21427', 'summary': '',
'_children': [{'videoFrameRate': '24p', 'audioCodec': 'aac', 'videoResolution': '1080', 'bitrate': '4441', 'audioProfile': 'lc', 'height': '1080', 'container': 'mkv', 'aspectRatio': '1.78', '_elementType': 'Media', 'videoCodec': 'h264', 'videoProfile': 'high', 'duration': '1275312', 'id': '50963',
'_children': [{'key': '/library/parts/51480/1486551812/file.mkv', 'size': '707980309', '_elementType': 'Part', 'id': '51480', 'videoProfile': 'high', 'duration': '1275312', 'audioProfile': 'lc',
'_children': [{'refFrames': '4', 'scanType': 'progressive', 'chromaSubsampling': '4:2:0', 'height': '1080', 'default': '1', 'hasScalingMatrix': '0', 'languageCode': 'eng', 'frameRateMode': 'cfr', 'streamType': '1', 'cabac': '1', 'level': '40', 'width': '1920', 'bitrate': '4441', 'index': '0', 'bitDepth': '8', '_elementType': 'Stream', 'id': '109342', 'pixelFormat': 'yuv420p', 'codecID': 'V_MPEG4/ISO/AVC', 'language': 'English', 'duration': '1275317', 'frameRate': '23.976', 'profile': 'high', 'codec': 'h264'}, {'samplingRate': '48000', 'selected': '1', 'streamType': '2', 'index': '1', 'default': '1', 'languageCode': 'eng', 'audioChannelLayout': 'stereo', '_elementType': 'Stream', 'channels': '2', 'codecID': 'A_AAC', 'language': 'English', 'id': '109343', 'duration': '1275312', 'profile': 'lc', 'codec': 'aac'}, {'languageCode': 'eng', '_elementType': 'Stream', 'format': 'srt', 'codecID': 'S_TEXT/UTF8', 'language': 'English', 'id': '109344', 'streamType': '3', 'index': '2', 'default': '1', 'codec': 'srt'}], 'file': '/media/hdd1/tv/Workaholics.S07E05.Faux.Chella.1080p.CC.WEBRip.AAC2.0.x264-BTW[rarbg]/Workaholics.S07E05.Faux.Chella.1080p.CC.WEBRip.AAC2.0.x264-BTW.mkv', 'container': 'mkv'}], 'width': '1920', 'audioChannels': '2'}, {'videoFrameRate': '24p', 'audioCodec': 'aac', 'videoResolution': '1080', 'bitrate': '4441', 'audioProfile': 'lc', 'height': '1080', 'container': 'mkv', 'aspectRatio': '1.78', '_elementType': 'Media', 'videoCodec': 'h264', 'videoProfile': 'high', 'duration': '1275312', 'id': '50964',
'_children': [{'key': '/library/parts/51481/1486551812/file.mkv', 'size': '707980309', '_elementType': 'Part', 'id': '51481', 'videoProfile': 'high', 'duration': '1275312', 'audioProfile': 'lc',
'_children': [{'refFrames': '4', 'scanType': 'progressive', 'chromaSubsampling': '4:2:0', 'height': '1080', 'default': '1', 'hasScalingMatrix': '0', 'languageCode': 'eng', 'frameRateMode': 'cfr', 'streamType': '1', 'cabac': '1', 'level': '40', 'width': '1920', 'bitrate': '4441', 'index': '0', 'bitDepth': '8', '_elementType': 'Stream', 'id': '109345', 'pixelFormat': 'yuv420p', 'codecID': 'V_MPEG4/ISO/AVC', 'language': 'English', 'duration': '1275317', 'frameRate': '23.976', 'profile': 'high', 'codec': 'h264'}, {'samplingRate': '48000', 'selected': '1', 'streamType': '2', 'index': '1', 'default': '1', 'languageCode': 'eng', 'audioChannelLayout': 'stereo', '_elementType': 'Stream', 'channels': '2', 'codecID': 'A_AAC', 'language': 'English', 'id': '109346', 'duration': '1275312', 'profile': 'lc', 'codec': 'aac'}, {'languageCode': 'eng', '_elementType': 'Stream', 'format': 'srt', 'codecID': 'S_TEXT/UTF8', 'language': 'English', 'id': '109347', 'streamType': '3', 'index': '2', 'default': '1', 'codec': 'srt'}], 'file': '/media/hdd1/tv/Workaholics/Workaholics Season 07/Workaholics.S07E05.Faux.Chella.1080p.CC.WEBRip.AAC2.0.x264-BTW[rarbg].mkv', 'container': 'mkv'}], 'width': '1920', 'audioChannels': '2'}, {'_elementType': 'User', 'id': '9608531', 'title': 'PhillipMid'}, {'address': '::ffff:84.211.211.7', 'title': 'TV UE55KU6075', 'platform': 'Samsung', 'product': 'Plex for Samsung', 'vendor': '', 'platformVersion': '2.4.0', 'state': 'playing', '_elementType': 'Player', 'version': '3.0.6 (2.10.8)', 'machineIdentifier': 'xbixedx5uyp', 'model': '', 'profile': 'Samsung', 'device': 'Samsung TV'}, {'complete': False, 'context': 'streaming', 'audioCodec': 'aac', 'remaining': 4081, 'audioChannels': 2, 'throttled': True, 'height': 720, 'videoDecision': 'transcode', 'container': 'mpegts', 'key': '6d94y2d0b25', 'audioDecision': 'copy', '_elementType': 'TranscodeSession', 'videoCodec': 'h264', 'speed': 0, 'duration': 1275000, 'width': 1280, 'protocol': 'hls', 'progress': 46.400001525878906}], 'grandparentKey': '/library/metadata/4994', 'parentRatingKey': '17543', 'duration': '1275312', 'ratingKey': '21427', 'parentIndex': '7', 'title': 'Episode 5', 'librarySectionID': '2', 'thumb': '/library/metadata/21427/thumb/1486581424', 'addedAt': '1486551819', 'art': '/library/metadata/4994/art/1486551832', 'grandparentTheme': '/library/metadata/4994/theme/1486551832', 'index': '5', 'grandparentRatingKey': '4994', '_elementType': 'Video', 'contentRating': 'TV-MA', 'parentKey': '/library/metadata/17543', 'grandparentTitle': 'Workaholics', 'guid': 'com.plexapp.agents.thetvdb://211751/7/5?lang=en'}], '_elementType': 'MediaContainer'}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -3,12 +3,51 @@
# @Author: KevinMidboe
# @Date: 2017-02-08 14:00:04
# @Last Modified by: KevinMidboe
# @Last Modified time: 2017-02-08 14:06:48
# @Last Modified time: 2017-02-08 23:19:53
from requests import get
try:
from plexSearch import plexSearch
except ImportError:
from plex.plexSearch import plexSearch
tmdbBaseURL = "https://api.themoviedb.org/3/"
def checkPlexExistance(tmdb, plex):
# THIS IS ONLY COMPARED ON YEAR
yearList = [movie["year"] for movie in plex]
print(yearList)
for movie in tmdb["movies"]:
print(movie["year"])
movie["exists"] = movie["year"] in str(yearList)
return tmdb
def createTMDBResultList(resContent):
movies = []
tvshows = []
for res in resContent["results"]:
if res["media_type"] == "movie":
id = res["id"]
title = res["original_title"]
year = res["release_date"][:4]
poster_path = res["poster_path"]
movies.append({"id": id, "title": title, "year": year, "poster_path": poster_path})
elif res["media_type"] == "tv":
id = res["id"]
name = res["original_name"]
year = res["first_air_date"][:4]
poster_path = res["poster_path"]
tvshows.append({"id": id, "title": name, "year": year, "poster_path": poster_path})
return { "movies": movies, "tvshows": tvshows }
def tmdbSearch(query, page=1):
requestType = "search/multi?"
requestAPI = "api_key=" + "9fa154f5355c37a1b9b57ac06e7d6712"
@@ -23,28 +62,10 @@ def tmdbSearch(query, page=1):
if response.status_code == 200:
resContent = response.json()
movies = []
tvshows = []
plexSearchRes = plexSearch(query)
tmdbSearchRes = createTMDBResultList(resContent)
for res in resContent["results"]:
if res["media_type"] == "movie":
id = res["id"]
title = res["original_title"]
year = res["release_date"][:4]
poster_path = res["poster_path"]
movies.append( {"id": id, "title": title, "year": year, "poster_path": poster_path} )
elif res["media_type"] == "tv":
id = res["id"]
name = res["original_name"]
year = res["first_air_date"][:4]
poster_path = res["poster_path"]
tvshows.append( {"id": id, "title": name, "year": year, "poster_path": poster_path} )
searchResults = { "movies": movies, "tvshows": tvshows }
return searchResults
return checkPlexExistance(tmdbSearchRes, plexSearchRes)
if __name__ == "__main__":
@@ -55,4 +76,4 @@ if __name__ == "__main__":
elif len(sys.argv) > 1:
print(tmdbSearch(sys.argv[1]))
else:
print(tmdbSearch("star+wars",2))
print(tmdbSearch("star+wars",1))