Naar inhoud springen

CampusSearch XBOX Plugin: verschil tussen versies

Uit CampusWiki
Verwijderde inhoud Toegevoegde inhoud
Jase (overleg | bijdragen)
Geen bewerkingssamenvatting
 
(5 tussenliggende versies door 2 gebruikers niet weergegeven)
Regel 1: Regel 1:
__TOC__
__TOC__
Dankzij het [[CampusSearch XML interface]] is er nu ook voor een xbox plugin gemaakt, met die je makkelijk vanuit je xbox films kunt zoeken en toevoegen.
Dankzij het [[CampusSearch XML interface]] is er nu ook voor een xbox plugin gemaakt, met die je makkelijk vanuit je xbox films kunt zoeken en toevoegen.

Dit alles in een [https://github.com/sparkline/kodi.campussearch plugin].
⚫
== Screenshots ==
{|
⚫
| [[afbeelding:xbox1.jpg|upright|thumb|Plugin]]
⚫
| [[afbeelding:xbox2.jpg|upright|thumb|Invoer]]
⚫
| [[afbeelding:xbox3.jpg|upright|thumb|Resultaten]]
|}


== Requirements ==
== Requirements ==
* modded xbox
* modded xbox
* [http://xbmc.org/ XBMC] installatie (het XBMC team ondersteunt de xbox niet meer. gelukkig maakt [http://www.xbmc4xbox.org/ XBMC4XBOX] nog verder met het project.
* [http://xbmc.org/ XBMC] installatie (het XBMC team ondersteunt de xbox niet meer. gelukkig maakt [http://www.xbmc4xbox.org/ XBMC4XBOX] nog verder met het project.)
** Getest op Build 30682 (06-10-2010), nieuwste builds zijn [http://sshcs.com/xbmc/ hier] verkrijgbar.
** Getest op Build 30682 (06-10-2010), nieuwste builds zijn [http://sshcs.com/xbmc/ hier] verkrijgbar.
* FTP access
* FTP access

== Installatie ==
== Installatie ==
De volgende code moet in een file "default.py" gesaved worden. Vervolgens wordt in het sub directory plugins/video/ van XBMC de map "CampusSearch" aangemakt en de default.py daar opgeslagen.
De volgende code moet in de file [http://wiki.student.utwente.nl/nl/wiki.php/CampusSearch_XBOX_Plugin#default.py default.py] gesaved worden. Vervolgens wordt in het sub directory plugins/video/ van XBMC de map "CampusSearch" aangemakt en de default.py daar opgeslagen.
Op onze xbox ziet het als volgt eruit:
Op onze xbox ziet het als volgt eruit:
<pre>E/apps/xbmc/plugins/video/CampusSearch/default.py</pre>
<pre>E/apps/xbmc/plugins/video/CampusSearch/default.py</pre>

== default.py ==
== default.py ==
Laatste wijziging''' 07-10-2010 17:31'''
Laatste wijziging''' 07-10-2010 17:31'''
Regel 119: Regel 129:
== Usage ==
== Usage ==
Het plugin is te vinden in XBMC onder Videos -> Video plugins -> CampusSearch. De werkwijze is self-explanatory.
Het plugin is te vinden in XBMC onder Videos -> Video plugins -> CampusSearch. De werkwijze is self-explanatory.
⚫
== Screenshots ==
⚫
[[afbeelding:xbox1.jpg|upright|thumb|alt text]]
⚫
[[afbeelding:xbox2.jpg|upright|thumb|alt text]]
⚫
[[afbeelding:xbox3.jpg|upright|thumb|alt text]]

== Hulp nodig? ==
== Hulp nodig? ==
Schrijf me een [mailto:haihappn@gmail.com mail] of kom ff langs (WBW 377-2 Voor)
Schrijf me een [mailto:haihappn@gmail.com mail] of kom ff langs (WBW 377-2 Voor)

Huidige versie van 19 mrt 2016 17:11

Dankzij het CampusSearch XML interface is er nu ook voor een xbox plugin gemaakt, met die je makkelijk vanuit je xbox films kunt zoeken en toevoegen.

Dit alles in een plugin.

Screenshots[bewerken]

Plugin
Invoer
Resultaten

Requirements[bewerken]

  • modded xbox
  • XBMC installatie (het XBMC team ondersteunt de xbox niet meer. gelukkig maakt XBMC4XBOX nog verder met het project.)
    • Getest op Build 30682 (06-10-2010), nieuwste builds zijn hier verkrijgbar.
  • FTP access

Installatie[bewerken]

De volgende code moet in de file default.py gesaved worden. Vervolgens wordt in het sub directory plugins/video/ van XBMC de map "CampusSearch" aangemakt en de default.py daar opgeslagen. Op onze xbox ziet het als volgt eruit:

E/apps/xbmc/plugins/video/CampusSearch/default.py

default.py[bewerken]

Laatste wijziging 07-10-2010 17:31

import urllib,re,xbmc,xbmcplugin,xbmcgui,os,sys
from xml.dom.minidom import parse

__language__ = xbmc.Language( os.getcwd() ).getLocalizedString

def getResults(film):
	notWantedKeywords = ["720p", "1080p", "1080i", "HDDVD", "Bluray", "Blueray"]
	unwantedKeywordFound = 0
	found = 0
	
	film  = film.replace(" ", "+")
	filmUrl = "http://search.student.utwente.nl/api/search?q=" + film + "&page=0&dirsonly=no&n=100"
	try:
		feed = urllib.urlopen(filmUrl)
		dom = parse(feed)	
	except Exception:
		message("Could not reach CampusSearch!")
	#check through all the <result>	
	for node in dom.getElementsByTagName('result'):
		#only take those which are online!
		if node.getElementsByTagName('online')[0].firstChild.nodeValue == 'yes':
			# we dont want bluray or any orther HD movie, the xbox cannot play it!
			for keyword in notWantedKeywords:
				if node.getElementsByTagName('full_path')[0].firstChild.nodeValue.find(keyword) != -1 or node.getElementsByTagName('name')[0].firstChild.nodeValue.find(keyword) != -1:
					unwantedKeywordFound = 1		
			if unwantedKeywordFound == 0:       
				# okay, everything seems clear, now lets get rid of the directories, we only want the files!
				#if node.getElementsByTagName('full_path')[0].firstChild.nodeValue.endswith(".avi") or node.getElementsByTagName('full_path')[0].firstChild.nodeValue.endswith(".mp4"):
				addDir(node.getElementsByTagName('name')[0].firstChild.nodeValue, node.getElementsByTagName('full_path')[0].firstChild.nodeValue, '')
				found = 1
			unwantedKeywordFound = 0;
	xbmcplugin.endOfDirectory(int(sys.argv[1]), 1)			
	if found != 1:
		message("nothing found!")		

#search for something
def GUIEditExportName(name):
	exit = True 
	while (exit):
		kb = xbmc.Keyboard('default', 'heading', True)
		kb.setDefault(name)
		kb.setHeading(__language__(33223))
		kb.setHiddenInput(False)
		kb.doModal()
		if (kb.isConfirmed()):
			name_confirmed  = kb.getText()
			name = name_confirmed
			exit = False
		else:
			message("nothing entered!") 
	return(name)
	
def message(text):
	dialog = xbmcgui.Dialog()
	dialog.ok("Error", text)

def addDir(name,path,iconimage):
	#root level, we only want the files or directories from the search results, not what is inside the folders
	if name != '':
		isDir = os.path.isdir(path)
		liz=xbmcgui.ListItem(name,'')
		#os.path.isdir does apparently not work for samba shares, so dirty hack has to be applied :)
		#if isDir:
		if path[len(path) - 4] != ".":
			url = sys.argv[0] + "?path=" + path + "/"
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,isDir)
		else:
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),path,liz)
	else:
		# os.listdir also does not work with samba shares, using xbmc httpapi as a workaround
		#folderContents = os.listdir(path)
		response = xbmc.executehttpapi("GetDirectory(" + path + ")")
		# remove <li> tags
		response = response.replace("<li>", "")
		# we only want the directories and files, so remove the absolute network path
		response = response.replace(path, "")
		# also "dir/" has to be just "dir"
		response = response.replace("/", "")
		# first token is a newline, we do not want that
		response = response.replace("\n", "", 1)
		# we split at each newline, so that we have a list of dirs & files
		folderContents = response.split('\n')
		for entries in folderContents:
			url = os.path.join(path,entries)
			#url = path + entries
			isDir = os.path.isdir(url)
			liz=xbmcgui.ListItem(entries,'')
			if isDir:
				url = sys.argv[0] + "?path=" + url + "/"
				xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz,isDir)
			else:
				xbmcplugin.addDirectoryItem(int(sys.argv[1]),url,liz)
		xbmcplugin.endOfDirectory(int(sys.argv[1]), 1)	
	return (0)

#this if will only be true if we want to see the content of a subfolder
if cmp (sys.argv[2][0:6],"?path=") == 0:
	addDir('', sys.argv[2][6:], '')
else:
	requestedMovie = ""
	requestedMovie = GUIEditExportName(requestedMovie)
	getResults(requestedMovie)

Usage[bewerken]

Het plugin is te vinden in XBMC onder Videos -> Video plugins -> CampusSearch. De werkwijze is self-explanatory.

Hulp nodig?[bewerken]

Schrijf me een mail of kom ff langs (WBW 377-2 Voor)