Hi,
hab herausgefunden, dass iTunes über ein JavaScript aufgerufen wird, welches von ax.phobos.apple.com an den Browser zurückgeschickt wird. Wie weiss ich nicht, aber wenn ich das Ganze per urllib2 simuliere, bekomme ich Folgendes zurück:
JavaScript:
Code: Alles auswählen
//
// iTunes Client Detection code
//
// This javascript library is tied intimately to MHBrowserRedirect.
// Note also that the iTunes U team links to this file on phobos, so check w/ Sugam before changing it.
//
// @author Mark Miller
var BROWSER_SAFARI = 1;
var BROWSER_FIREFOX = 2;
var BROWSER_INTERNET_EXPLORER = 3;
var BROWSER_OTHER = 4;
var ITUNES_INSTALLED_COOKIE_NAME="iTunesPresent";
function iTunesDetected() {
// if we've already figured out that iTunes is present, rely on that data:
if ('true' == getCookie(ITUNES_INSTALLED_COOKIE_NAME)) return true;
// If we are on the Mac, assume that iTunes is installed.
if (-1 != navigator.userAgent.indexOf("Macintosh")) return true;
if (BROWSER_INTERNET_EXPLORER == detectedBrowser()) {
return iTunesActiveXComponentInstalled();
}
// last chance:
return iTunesMozillaPluginDetected();
}
function detectedBrowser() {
if (-1 != navigator.userAgent.indexOf("AppleWebKit")) return BROWSER_SAFARI;
if (-1 != navigator.userAgent.indexOf("Firefox")) return BROWSER_FIREFOX;
if (-1 != navigator.userAgent.indexOf("MSIE ")) return BROWSER_INTERNET_EXPLORER;
else return BROWSER_OTHER;
}
/**
* We interpret the presence of the iTunes ActiveX Component to mean that iTunes itself has been installed.
* @return true if the iTunes ActiveX Component was successfully loaded.
*/
function iTunesActiveXComponentInstalled() {
var detectObj = document.getElementById('iTunesDetectorIE');
var returnVal = false; // If we can't load the ActiveX control, assume we do not have ITMS
if ((detectObj != null) && (typeof(detectObj) != "undefined")) {
if (typeof(detectObj.IsITMSHandlerAvailable) != "undefined") {
returnVal = detectObj.IsITMSHandlerAvailable;
dbg(typeof(detectObj.IsITMSHandlerAvailable));
}
if ((returnVal == null) || (typeof (returnVal) == "undefined")) returnVal = false;
}
dbg("ActiveX Control result: " + returnVal);
return returnVal;
}
/**
* We interpret the presence of the iTunes Firefox plugin to mean that iTunes itself has been installed.
* @return true if the iTunes Firefox plugin was successfully loaded.
*/
function iTunesMozillaPluginDetected() {
var result = false;
if (navigator.plugins && navigator.plugins.length > 0) {
for (var i=0; i < navigator.plugins.length; i++ ) {
var plugin = navigator.plugins[i];
var pluginName = plugin.name;
if (pluginName.indexOf("iTunes Application Detector") > -1) { result = true }
}
}
info("FF plugin detected: " + result);
return result;
}
/**
* This is the main entry point from WebObjects code. See MHBrowserRedirect.java
*
* @param url the url to open if iTunes is installed
* @param downloadUrl the url to go to to download iTunes
* @param overridePanelId the id to unhide if the browser is firefox/opera.
* @param noClose if true, don't close the browser window after opening iTunes.
*/
function itmsOpen(url, downloadUrl, overridePanelId, noClose) {
if (null != getCookie('recentlyRedirected')) noClose = true;
setCookie('recentlyRedirected', true, 4000);
if (iTunesDetected()) {
setCookie(ITUNES_INSTALLED_COOKIE_NAME, true, 9999999999);
if (noClose) {
//info("itmsOpen(): Opening " + url + "\nThis window will remain open.");
// we can't set window.location.href directly because the current page will not
// be rendered (at least in Safari 416.12). The odd thing is that even a window.alert()
// hides this bug, if it is a bug.
setTimeout('window.location.href = "'+url+'"', 1);
return true;
} else {
return replaceCurrentPageWithUrl(url);
}
}
else {
if (BROWSER_INTERNET_EXPLORER == detectedBrowser()) {
// take IE users straight to the download page because we're sure they don't
// have iTunes installed (they would have had the ActiveX component show up)
window.location.replace(downloadUrl);
}
else { // for all other browsers, let the user tell us if iTunes is installed:
document.getElementById(overridePanelId).style.display='block';
}
}
return true;
}
/**
* Open the given url (using iTunes) and make a best effort to close or go back in the current window.
*/
function replaceCurrentPageWithUrl(url) {
window.location.href = url;
info("Window History Length: " + window.history.length);
if (window.history.length < 2) {
setTimeout('window.close()', 100);
} else {
setTimeout('window.history.back()', 100);
}
return true;
}
function setCookie(cookieName,cookieValue,ttlMillis) {
var expire = new Date();
expire.setTime(expire.getTime() + ttlMillis);
var cookie = cookieName + "=" + escape(cookieValue) + "; expires=" + expire.toGMTString();
info("setCookie(): " + cookie);
document.cookie = cookie;
}
function getCookie(cookieName) {
if (null == document.cookie || null == cookieName) return null;
var cookies = document.cookie.split(';');
var result = null;
for (var i=0; i < cookies.length; i++) {
var c = cookies[i];
var keyValue = c.split('=');
if (-1 < keyValue[0].indexOf(cookieName)) {
result = unescape(keyValue[1]);
break;
}
}
info("getCookie(" + cookieName + "): " + result);
return result;
}
function dbg(str) {
// return alert(str);
}
function info(str) {
// return alert(str);
}
Jetzt will ich das mit Python nachbauen. Leider verstehe ich nichts von Java oder JS. Mich interessiert eigentlich nur, an welcher Stelle iTunes gestartet und die url übergeben wird. Vieleicht weiss das ja jemand von euch ?
Gruß, Seven