mirror of
https://github.com/KevinMidboe/Node-Com-Handler.git
synced 2025-10-29 09:40:27 +00:00
Done with most of the requests of movies and started most of the dyn loading of elements
This commit is contained in:
45
html/css/style.css
Normal file
45
html/css/style.css
Normal file
@@ -0,0 +1,45 @@
|
||||
.onoffswitch {
|
||||
position: relative; width: 85px;
|
||||
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
|
||||
}
|
||||
.onoffswitch-checkbox {
|
||||
display: none;
|
||||
}
|
||||
.onoffswitch-label {
|
||||
display: block; overflow: hidden; cursor: pointer;
|
||||
border: 2px solid #FFFFFF; border-radius: 20px;
|
||||
}
|
||||
.onoffswitch-inner {
|
||||
display: block; width: 200%; margin-left: -100%;
|
||||
transition: margin 0.3s ease-in 0s;
|
||||
}
|
||||
.onoffswitch-inner:before, .onoffswitch-inner:after {
|
||||
display: block; float: left; width: 50%; height: 32px; padding: 0; line-height: 32px;
|
||||
font-size: 12px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.onoffswitch-inner:before {
|
||||
content: "Movies";
|
||||
padding-left: 9px;
|
||||
background-color: #21D278; color: #FFFFFF;
|
||||
}
|
||||
.onoffswitch-inner:after {
|
||||
content: "Shows";
|
||||
padding-right: 9px;
|
||||
background-color: #EEEEEE; color: #999999;
|
||||
text-align: right;
|
||||
}
|
||||
.onoffswitch-switch {
|
||||
display: block; width: 23px; margin: 4.5px;
|
||||
background: #FFFFFF;
|
||||
position: absolute; top: 0; bottom: 0;
|
||||
right: 49px;
|
||||
border: 2px solid #FFFFFF; border-radius: 20px;
|
||||
transition: all 0.3s ease-in 0s;
|
||||
}
|
||||
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
|
||||
margin-left: 0;
|
||||
}
|
||||
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
|
||||
right: 0px;
|
||||
}
|
||||
@@ -6,6 +6,25 @@ button.onclick = function () {
|
||||
queryTMDB(text);
|
||||
}
|
||||
|
||||
function clearSearchResults() {
|
||||
var displayNode = document.getElementById("display");
|
||||
while (displayNode.firstChild) {
|
||||
displayNode.removeChild(displayNode.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
function toggle(button) {
|
||||
toggleNode = document.getElementById("myonoffswitch");
|
||||
console.log(toggleNode);
|
||||
|
||||
|
||||
if(toggleNode.value=="movies"){
|
||||
toggleNode.value="shows";}
|
||||
|
||||
else if(toggleNode.value=="shows"){
|
||||
toggleNode.value="movies";}
|
||||
}
|
||||
|
||||
function queryTMDB(query) {
|
||||
var data = "{}";
|
||||
|
||||
@@ -14,6 +33,8 @@ function queryTMDB(query) {
|
||||
|
||||
xhr.addEventListener("readystatechange", function () {
|
||||
if (this.readyState === this.DONE) {
|
||||
clearSearchResults()
|
||||
|
||||
var display = document.getElementById("display");
|
||||
var jsonObj = JSON.parse(this.responseText);
|
||||
console.log(jsonObj.movies);
|
||||
@@ -27,14 +48,19 @@ function queryTMDB(query) {
|
||||
var poster_path = "http://image.tmdb.org/t/p/w500"+jsonObj.movies[key].poster_path;
|
||||
else
|
||||
var poster_path = "images/image_nf.svg";
|
||||
|
||||
var exists = jsonObj.movies[key].exists;
|
||||
|
||||
var node = document.createElement("li"); // Create a <li> node
|
||||
var imageNode = document.createElement('img');
|
||||
var textNode = document.createTextNode(title); // Create a text node
|
||||
var buttonNode = document.createElement("span");
|
||||
var button2Node = document.createElement("span");
|
||||
buttonNode.innerHTML = '<button onclick="request('+ id +')">REQUEST</button>';
|
||||
button2Node.innerHTML = '<button onclick="request('+ id +')">FORCE REQUEST</button>';
|
||||
if (!exists) {
|
||||
buttonNode.innerHTML = '<button onclick="request('+ id +')">REQUEST</button>';
|
||||
}
|
||||
else
|
||||
button2Node.innerHTML = '<button onclick="request('+ id +')">FORCE REQUEST</button>';
|
||||
|
||||
imageNode.src = poster_path;
|
||||
imageNode.style.width = "500px";
|
||||
@@ -48,6 +74,9 @@ function queryTMDB(query) {
|
||||
|
||||
});
|
||||
}
|
||||
else {
|
||||
console.log("404");
|
||||
}
|
||||
});
|
||||
|
||||
xhr.open("GET", "http://localhost:63590/api/v1/plex/request?query="+query);
|
||||
|
||||
@@ -2,10 +2,20 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>tmdb.org Search Displayer</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<input type='text' id='link_id'>
|
||||
<input type='button' id='btnSearch' value='Search' onClick="search(this)"'>
|
||||
|
||||
<div class="onoffswitch">
|
||||
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" value="movies" onClick="toggle(this)" checked>
|
||||
<label class="onoffswitch-label" for="myonoffswitch">
|
||||
<span class="onoffswitch-inner"></span>
|
||||
<span class="onoffswitch-switch"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<p id="display"></p>
|
||||
</body>
|
||||
|
||||
|
||||
BIN
plex/__pycache__/plexSearch.cpython-34.pyc
Normal file
BIN
plex/__pycache__/plexSearch.cpython-34.pyc
Normal file
Binary file not shown.
Binary file not shown.
@@ -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')
|
||||
@@ -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())
|
||||
|
||||
13
plex/testData/watchingSingleEpisode.txt
Normal file
13
plex/testData/watchingSingleEpisode.txt
Normal 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'}
|
||||
20
plex/testData/watchingTwoEpisodes.txt
Normal file
20
plex/testData/watchingTwoEpisodes.txt
Normal file
File diff suppressed because one or more lines are too long
6
plex/testData/watchingTwoStreams.txt
Normal file
6
plex/testData/watchingTwoStreams.txt
Normal file
File diff suppressed because one or more lines are too long
67
plex/tmdb.py
67
plex/tmdb.py
@@ -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))
|
||||
Reference in New Issue
Block a user