R0ci0-V3rd3al / JTube

Youtube client based on Invidious API for Java devices with MIDP 2.0 support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JTube

Youtube client based on Invidious API for Java devices with MIDP 2.0 support

FAQ

JTube Lite: https://github.com/shinovon/JTubeLite

Building

You will need:
S40 5th Edition SDK
JDK 1.5.0 (to run S40 emulator)
Last version of Eclipse SDK
MTJ plugin 2.0.1

Clone the repository

Import project from directory in Eclipse SDK

Open "Application Descriptor" in Package Explorer image

Click on "Create package" image

Check the "Use deployment directory"

Uncheck "Obfuscate the code" if you don't want to optimize code

Then press "Finish"

image

Builded JAR & JAD files will appear at <project path>/deployed/S40_5th_Edition_SDK/

Setting up your own server

Glype proxy: https://github.com/vincentclee/glype

stream.php (HTTP Streaming proxy for older versions): https://github.com/Athlon1600/youtube-downloader

hproxy.php (Image proxy):

<?php

function reqHeaders($arr, $url = null) {
	$res = array();
	foreach($arr as $k=>$v) {
		$lk = strtolower($k);
		if($lk == 'host' && isset($url)) {
			$dom = '';
			if(strpos($url, 'http://') == 0) {
				$dom = substr($url, 7);
			} else if(strpos($url, 'https://') == 0) {
				$dom = substr($url, 8);
			} else {
				$dom = $url;
			}
			$pos = strpos($dom, '/');
			if($pos) {
				$dom = substr($dom, 0, $pos);
			}
			array_push($res, 'Host: '. $dom);
		} else if($lk != 'connection' && $lk != 'accept-encoding' && $lk != 'user-agent') {
			array_push($res, $k . ': ' . $v);
		}
	}
	return $res;
}

function handleHeaders($str) {
	$headersTmpArray = explode("\r\n", $str);
	for ($i = 0; $i < count($headersTmpArray); ++$i) {
		$s = $headersTmpArray[$i];
		if(strlen($s) > 0) {
			if(strpos($s, ":")) {
				$k = substr($s, 0 , strpos($s, ":"));
				$v = substr($s, strpos($s, ":" )+1);
				$lk = strtolower($k);
				if(/*$lk != 'server' && */$lk != 'connection' && $lk != 'transfer-encoding' && $lk != 'location') {
					header($s, true);
				}
			}
		}
	}
}
$url = urldecode($_SERVER['QUERY_STRING']);
$lu = strtolower($url);

if(substr($lu, 0, 5) == 'file:' || substr($lu, 0, 4) == "ftp:") {
	return;
}
unset($lu);
$reqheaders = reqHeaders(getallheaders(), $url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
if(isset($_SERVER['HTTP_USER_AGENT']))
	curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_HTTPHEADER, $reqheaders);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, true);
$res = curl_exec($ch);
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($res, 0, $headerSize);
$body = substr($res, $headerSize);
handleHeaders($header);
curl_close($ch);
echo $body;
?>

About

Youtube client based on Invidious API for Java devices with MIDP 2.0 support

License:MIT License


Languages

Language:Java 100.0%