powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / HTML, JavaScript, VBScript, CSS [игнор отключен] [закрыт для гостей] / Нужна помощь. Js для PSPTube.
1 сообщений из 1, страница 1 из 1
Нужна помощь. Js для PSPTube.
    #35683048
Irvin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
На такую замечательную вещь как PSP есть программа для просмотра Youtube-подобных ресурсов. Добавление таких сайтов можно осуществить с помощью Js-ов. Сам я в скриптовании ноль, поэтому прошу кого-нибудь написать скрипт для просмотра видео на Rutube.

Есть общий пример для создания скрипта:
Общий вариант
//
// Ultimate PSPTube Functions
//

//Gets the list of sites and displays them in the order specified
function CallGate_GetSiteList()
{
var site = new Array();

//Site order length is longer than site length
if(site_order.length > SiteList.length){
for(var i = 0; i < SiteList.length; i++) {
site[i] = SiteList[i];
}
return site;
}

//Site order array contains a site that doesn't exist
for(var i = 0; i < site_order.length; i++) {
var found = 0;
for(var i2 = 0; i2 < SiteList.length; i2++) {
if(SiteList[i2].Name == site_order[i]){found = 1;}
}
if(found == 0){
for(var i3 = 0; i3 < SiteList.length; i3++) {
site[i3] = SiteList[i3];
}
return site;
}
}

//Order sites
for(var i = 0; i < SiteList.length; i++) {
for(var i2 = 0; i2 < SiteList.length; i2++) {
if(SiteList[i2].Name == site_order[i]){site[site.length] = SiteList[i2];}
}
}

return site;
}

//Gets the video url
function CallGate_VideoURLResolver( url, option )
{
for(var i = 0; i < SiteList.length; i++) {
if(SiteList[i].CheckURL( url, option ) == 1) {
return SiteList[i].GetURL( url, option );
}
}
return null;
}

//Performs the search
function CallGate_SearchSite( sitename, keyword, start_index, length, option )
{
for(var i = 0; i < SiteList.length; i++) {
if(SiteList[i].Name == sitename) {
return SiteList[i].Search( keyword, start_index, length, option );
}
}
return null;
}


//Replace all diacratics in a string with their similar letter
function replaceDiacritics(s)
{
var s;

var diacritics =[
/[\300-\306]/g, /[\340-\346]/g, // A, a
/[\310-\313]/g, /[\350-\353]/g, // E, e
/[\314-\317]/g, /[\354-\357]/g, // I, i
/[\322-\330]/g, /[\362-\370]/g, // O, o
/[\331-\334]/g, /[\371-\374]/g, // U, u
/[\321]/g, /[\361]/g, // N, n
/[\307]/g, /[\347]/g, // C, c
];

var chars = ['A','a','E','e','I','i','O','o','U','u','N','n','C','c'];

for (var i = 0; i < diacritics.length; i++){
s = s.replace(diacritics[i],chars[i]);
}

return s;
}

//Removes all diacratics in a string
function removeDiacritics(s)
{
var s;

var diacritics =[
/[\300-\306]/g, /[\340-\346]/g, // A, a
/[\310-\313]/g, /[\350-\353]/g, // E, e
/[\314-\317]/g, /[\354-\357]/g, // I, i
/[\322-\330]/g, /[\362-\370]/g, // O, o
/[\331-\334]/g, /[\371-\374]/g, // U, u
/[\321]/g, /[\361]/g, // N, n
/[\307]/g, /[\347]/g, // C, c
];

for (var i = 0; i < diacritics.length; i++){
s = s.replace(diacritics[i],"");
}

return s;
}

//Removes all unidentified characters in a string
function removeUnidentifiedChars(text)
{
var contents = text.match(/(.*?);/g);
if(contents == null){return text;}
for(var i = 0; i < contents.length; i++){
text = text.replace(contents[i], "");
}
return text;
}

function splitTo2Lines(text, line_length)
{
var pos = text.indexOf("\n");
if((pos == -1 || pos > line_length) && text.length > line_length){
pos = text.lastIndexOf(" ", line_length);
if(pos != -1){ text = text.substring(0, pos) + "\n" + text.substring(pos + 1, text.length); }
}
return text;
}

function TimestringToSeconds(timestring)
{
var pos = timestring.indexOf(":");
var mins = timestring.substring(0, pos);
var secs = timestring.substring(pos + 1, timestring.length);
if(mins.substring(0, 1) == "0" && mins.length > 1){
mins = mins.substring(1, mins.length);
}
if(secs.substring(0, 1) == "0" && secs.length > 1){
secs = secs.substring(1, secs.length);
}
var mins = parseInt(mins);
var secs = parseInt(secs);
if(mins == null || mins == -1){ var mins = 0; }
if(secs == null || secs == -1){ var secs = 0; }
mins = (mins * 60) + secs;
return mins;
}

function ToFilename(text)
{
return text.replace(/\\/g, "").replace(/\//g, "").replace(/\:/g, "").replace(/\*/g, "").replace(/\?/g, "").replace(/\"/g, "").replace(/\</g, "").replace(/\>/g, "").replace(/\|/g, "") + ".flv";
}

function ImproveText(text)
{
var contents = text.match(/\<a href\=\"(.*?)\"\>(.*?)\<\/a\>/g);
while(contents != null){
text = text.replace("<a href=\"" + RegExp.$1 + "\">" + RegExp.$2 + "</a>", RegExp.$2);
contents = text.match(/\<a href\=\"(.*?)\"\>(.*?)\<\/a\>/g);
}
contents = text.match(/\<img src\=\"(.*?)\"\>/g);
while(contents != null){
text = text.replace("<img src=\"" + RegExp.$1 + "\">", "");
contents = text.match(/\<img src\=\"(.*?)\"\>/g);
}
return text.replace(/\<b\>/g, "").replace(/\<\/b\>/g, "").replace(/\<u\>/g, "").replace(/\<\/u\>/g, "").replace(/\<i\>/g, "").replace(/\<\/i\>/g, "").replace(/\\'/g, "'").replace(/&/g, "&").replace(/"/g, "\"").replace(/'/g, "'").replace(/'/g, "'").replace(/\\\'/g, "'").replace(/–/g, "-").replace(/'/g, "'");
}


И конктретно для youtube :
Youtube
// YouTube.js for PSPTube
// Made By JK108

function YouTube_CheckURL( url, option )
{
if (url.match("http://www.youtube.com/watch") == "http://www.youtube.com/watch"){
return 1;
} else{
return 0;
}
}

/*
Get a YouTube URL
*/
function YouTube_GetURL( url, option )
{
// get video file URL
var id = url.match( /^http:\/\/www\.youtube\.com\/watch\?v=(.*)/ );
if(id == null) { return null; /* ID not valid */ }
id = id[1];

var urltoken = "http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=" + id;
var contents = GetContents( urltoken );
var token = contents.match( /<t>(.*)<\/t>/ );
var token = token[1];
var video_url = "http://youtube.com/get_video?video_id=" + id + "&t=" + token;

return video_url;
}

function YouTube_Search( keyword, start_index, length, option )
{
var result = new Object();
result.keyword = keyword; // Search
result.VideoInfo = new Array(); // Results in sequence
result.start = start_index; // Index of first result
result.end = 0;
result.total = -1;


result.start = (((result.start - 1) / 10) * 20) + 1;


if(result.start < 20){
var contents = GetContents( "http://uk.youtube.com/results?search_query=" + keyword.replace(/ /g, "+") + "&search_type=&aq=f" );
} else{
var num = 1 + ((result.start - 1) / 20);
var contents = GetContents( "http://uk.youtube.com/results?search_query=" + keyword.replace(/ /g, "+") + "&page=" + num );
}
if(contents == null) { return null; /* failed to get page */ }


if(contents.match("No videos found for <span >") == "No videos found for <span >"){ result.total = 0; return result; }
if(contents.match("</strong> of <strong>millions</strong>") == "</strong> of <strong>millions</strong>"){
total = 1000000;
} else{
var pos = contents.indexOf('</strong> of about <strong>');
contents = contents.substring(pos + 27, contents.length);
pos = contents.indexOf("</strong>");
var total = contents.substring(0, pos).replace(",", "");
}
result.total = total;


while(1){
pos = contents.indexOf("<a id=\"video-watch-url-");

if(pos != -1){
//Get URL
contents = contents.substring(pos + 23, contents.length);
pos = contents.indexOf("\" href=\"");
var url = "http://www.youtube.com/watch?v=" + contents.substring(0, pos);
//Get Thumbnail
pos = contents.indexOf("><img src=\"");
contents = contents.substring(pos + 11, contents.length);
pos = contents.indexOf("\" class=");
var thumb_url = contents.substring(0, pos);
//Title
pos = contents.indexOf("\" title=\"");
contents = contents.substring(pos + 9, contents.length);
pos = contents.indexOf("\" alt=");
var title = ImproveText(contents.substring(0, pos));
//Description
pos = contents.indexOf("id=\"video-description");
contents = contents.substring(pos + 21, contents.length);
pos = contents.indexOf("\n");
contents = contents.substring(pos + 6, contents.length);
if(contents.substring(0, 1) == "\t"){
pos = contents.indexOf("\n");
contents = contents.substring(pos + 2, contents.length);
}
pos = contents.indexOf("\n");
var description = ImproveText(contents.substring(0, pos));
if(description == null || description == ""){description = title;}
description = splitTo2Lines(description, 57);
//Views
pos = contents.indexOf("class=\"vlviewcount\">");
contents = contents.substring(pos + 20, contents.length);
pos = contents.indexOf("</span>");
var views = parseInt(contents.substring(0, pos).replace(",", ""));
//Length
pos = contents.indexOf("class=\"runtime\">");
contents = contents.substring(pos + 16, contents.length);
pos = contents.indexOf("</div>");
var length = contents.substring(0, pos);
var length = TimestringToSeconds(length);

info = new Object();
info.URL = url;
info.ThumbnailURL = thumb_url;
info.Title = title;
info.Description = description;
info.ViewCount = views;
info.LengthSeconds = length;
info.SaveFilename = ToFilename(title);
info.attr = 7;
result.VideoInfo.push( info );
if(result.start + (result.VideoInfo.length - 1) == result.total){break;}
} else{
break;
}
}


if(result.VideoInfo.length) {
result.end = result.start + (result.VideoInfo.length - 1);
} else {
result.total = 0; // no results.
}

if(result.VideoInfo.length != 20){result.total = result.end;}

return result;
}

// Service metadata
var YouTube = new Object();
YouTube.Name = "YouTube"; /* Service name */
YouTube.Description = "YouTube"; /* Service description */
YouTube.SearchDesc = "YouTube"; /* Service search screen description */
YouTube.SearchOSKMode = 1; /* OSK mode 1: English only 2: Japanese */
YouTube.CheckURL = YouTube_CheckURL; /* CheckURL function */
YouTube.GetURL = YouTube_GetURL; /* GetURL function */
YouTube.Search = YouTube_Search; /* Search function */

// add YouTube to site list
SiteList.push( YouTube );


Заранее спасибо за помощь (или за попытки помочь, или просто за ответы) от десятков тысяч пользователей PSP по всей России!!!
...
Рейтинг: 0 / 0
1 сообщений из 1, страница 1 из 1
Форумы / HTML, JavaScript, VBScript, CSS [игнор отключен] [закрыт для гостей] / Нужна помощь. Js для PSPTube.
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]