Post Reply 
PSPTube++ 200802224
JS support
Author Message
matchung
Turok Makto

Posts: 1,744.2413
Threads: 180
Joined: 5th Mar 2007
Reputation: -1.62846
E-Pigs: 162.3154
Offline
Post: #1
PSPTube++ 200802224
wee can now add our favorite sites support by js scripts:
Quote:# JavaScript can be added at the site.
# This based on the part of the search for additional specifications.
# Video Search part of the specification is subject to change

click me for leeching

script example:

Spoiler for code:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// AmebaVision
// UTF-8

/*
 URLをチェックする関数

 URLを調べてVideoのダウンロードに対応しているなら1を返す。
 対応してないURLなら0を返す。

 未実装)
 対応している検索URLなら2を返す。
*/
function AmebaVision_CheckURL( url, option )
{
	// ex.) http://vision.ameba.jp/watch.do?movie=123456
	if(url.match( /^http:\/\/vision\.ameba\.jp\/watch\.do\?movie=\d{6}$/ )) {
		return 1;
	} else {
		return 0;
	}
}

/*
 Videoを取得するURLを返す
*/
function AmebaVision_GetURL( url, option )
{
	// ビデオIDを取得する
	// "movie="以降に続くの6桁の数字
	var video_id = url.match( /^http:\/\/vision\.ameba\.jp\/watch\.do\?movie=(\d{6})$/ );
	if(video_id == null) { return null; /* ID取得失敗 */ }
	video_id = RegExp.$1;

	// APIを使ってビデオの詳細を取得
	// -GetContents関数は単純に指定されたURLの内容を取得する関数。
	//  クッキーの処理は行わないし、接続もクローズする。
	//  エラーが起きた場合は、nullが返る。
	//  将来的には例外を投げることで実装するかもしれない。
	var contents = GetContents( "http://vision.ameba.jp/api/get/detailMovie.do?movie=" + video_id );
	if(contents == null) { return null; /* 取得に失敗 */ }

	// ビデオのURLを解析
	var video_url = contents.match( /<imageUrlSmall>(.*?)_/ );	/* <imageUrlSmall>~_までを取得 */
	if(video_url == null) { return null; /* 解析失敗 */ }
	video_url = RegExp.$1;
	video_url = video_url.replace( /visionimg\.ameba/, "visionmovie2.ameba" );
	//video_url = video_url.replace( /http:\/\/vi1/, "http://vm1" );
	video_url = video_url.replace( /http:\/\/vi/, "http://vm" );
	video_url = video_url.replace( /\/jpg\//, "/flv/" ) + ".flv";

	return video_url;
}

/*
 動画を検索する
 
 keyword     : 検索するキーワード
 start_index : 開始件数(1オリジン)
 length      : 検索する件数
 option      : 検索条件 現在、具体的な値は未定義で0となる
 
 返す物
 
 .keyword                            : 文字列   検索したキーワード
 .total                              : 整数     検索した結果の総数
                                                -1 : 総数不明
                                                 0 : 検索して結果がなかった
                                                 >0:総数
 .start                              : 整数     開始件数(1オリジン)
 .end                                : 整数     終了件数(1オリジン)
 .VideoInfo                          : 配列     動画情報
 .VideoInfo[n].Author                : 文字列   著作権者
 .VideoInfo[n].Title                 : 文字列   動画のタイトル
 .VideoInfo[n].LengthSeconds         : 整数     動画の総再生時間(秒単位) 
 .VideoInfo[n].RatingAvg             : 浮動小数 レイティング
 .VideoInfo[n].RatingCount           : 整数     レイティング投票数
 .VideoInfo[n].Description           : 文字列   説明
 .VideoInfo[n].ViewCount             : 整数     見た、聞いた数
 .VideoInfo[n].UploadTime            : 文字列   アップロードしたUNIX時間
                                                ?
 .VideoInfo[n].CommentCount          : 整数     コメント数
 .VideoInfo[n].MylistCount           : 整数     マイリスト登録数
 .VideoInfo[n].Tags                  : 文字列   タグ。スペース区切り ex.) "tag1 tag2 tag3"
 .VideoInfo[n].URL                   : 文字列   動画ページのURL
 .VideoInfo[n].ThumbnailURL          : 文字列   サムネイルのURL
 .VideoInfo[n].SaveFilename          : 文字列   セーブするときのファイル名
                                                廃止予定 動画固有のIDを設定しておいてください。
 .VideoInfo[n].attr                  : 整数     動画属性 下記の値をORで設定
                                                1 : リードオンリー(削除できない)
                                                2 : ダウンロードできる
                                                4 : 再生するにはネットワークに接続する必要がある
                                                普通は、1+2+4で7
                                                MSのディレクトリなどは、削除できないので1になる
                                                MSのファイルは、0
 .VideoInfo[n].child                 :          子供
 .VideoInfo[n].parent                :          親
*/
function AmebaVision_Search( keyword, start_index, length, option )
{
	var pattern = /\t\t<div\sclass\=\"movieDetail\">((.|\r|\n)*?)\t\t<\/div>/g;
	var result = new Object();
    result.keyword   = keyword;		// 検索したキーワード
	result.VideoInfo = new Array();	// 検索結果が入る配列
	result.start     = start_index;	// 検索結果の始めの項目
	result.end       = 0;
	result.total     = -1;

	// APIが使えないので検索ページでうにゃうにゃする
	var url_base = "http://vision.ameba.jp/search/keyword/new.do?keyword=" + PSPTube.encodeURI( keyword ) + "&activePage=";

	var nPage = Math.floor( (start_index - 1) / 24 ) + 1;	/* 検索開始ページ */
	var nIndex = (nPage - 1) * 24 + 1;						/* 開始インデックス */
	while(nIndex < (start_index + length)) {
		var url = url_base + String( nPage );
		var contents = GetContents( url );
		if(contents == null) { return null; /* 取得に失敗 */ }
		/* トータルの件数取得 */
		if(contents.match( /<em>((\d*?)件中)<\/em>/ )) {
			result.total = RegExp.$1 - 0;
		}
		var i = nIndex;
		while(pattern.exec( contents ) != null) {
			if((start_index <= i) && (i < (start_index + length))) {
				var item = RegExp.$1;	/* <item>~</item> videoの情報 */
				var info = new Object();

				// タイトル
				if(item.match( /jpg\"\salt\=\"(.*?)\"/ )) {
					info.Title = RegExp.$1;
					info.Description = info.Title;	// 説明
					if(item.match( /adultFilterSmall/ )) {
						info.Description = "Adult\n" + info.Description;	/* 大人な動画 目印 */
					}
				}
				// サムネイル
				if(item.match( /<img\ssrc\=\"(.*?)\"/ )) {
					info.ThumbnailURL = RegExp.$1;
				}
				// URL
				if(item.match( /movie\=(\d*)/ )) {
					var tmp = "http://vision.ameba.jp/watch.do?movie=" + String( RegExp.$1 );
					if(item.match( /adultFilterSmall/ )) {
						/* 大人なのは見れないので除外する */
					} else {
						info.URL = tmp;
					}
				}
				// 再生回数
				if(item.match( /<dl\sclass\=\"viewerCount\"><dt>視聴回数:<\/dt><dd>(\d*?)\sPV<\/dd><\/dl>/ )) {
					info.ViewCount = RegExp.$1 - 0;
				}
				// お気に入り数
				if(item.match( /<dl\sclass\=\"favoriteCount\"><dt>お気に入り数:<\/dt><dd>(\d*?)<\/dd><\/dl>/ )) {
					info.MylistCount = RegExp.$1 - 0;
				}
				// コメント数
				if(item.match( /<dl\sclass\=\"commentCount\"><dt>コメント数\:<\/dt><dd>(\d*?)<\/dd><\/dl>/ )) {
					info.CommentCount = RegExp.$1 - 0;
				}
				// 動画の再生時間(秒単位)
				if(item.match( /<span\sclass\=\"movieTime\">\((\d{2})\:(\d{2})\)<\/span>/ )) {
					info.LengthSeconds = (RegExp.$1 - 0) * 60 + (RegExp.$2 - 0);
				}
				// レイティングをgoodとbadから作ってみる
				var good = 0;
				var bad = 0;
				if(item.match( /alt\=\"GOOD\"\s\/><\/dt><dd>\:(\d*?)<\/dd><\/dl>/ )) {
					good = RegExp.$1 - 0;
				}
				if(item.match( /alt\=\"BAD\"\s\/><\/dt><dd>\:(\d*?)<\/dd><\/dl>/ )) {
					bad = RegExp.$1 - 0;
				}
				if(good + bad) {
					info.RatingCount = good + bad;						/* レイティング投票数    */
					info.RatingAvg   = (good / (good + bad)) * 5.0;		/* レイティング5段階評価 */
				}

				info.attr = 7;
				result.VideoInfo.push( info );
			}
			i++;
		}
		nIndex = nIndex + 24;
		nPage++;
	}
	if(result.VideoInfo.length) {
		result.end   = result.start + (result.VideoInfo.length - 1);
	} else {
		result.total = 0;	// 検索結果無かった
	}
	return result;
}

// サイトオブジェクトを作成
var AmebaVision = new Object();
AmebaVision.Name          = "AmebaVision";			/* 動画サイト名 */
AmebaVision.Description   = "AmebaVision";			/* 動画サイトの説明 */
AmebaVision.SearchDesc    = "AmebaVision";			/* 検索時の説明 */
AmebaVision.SearchOSKMode = 2;						/* 検索時のOSKモード 1: English only  2: Japanese */
AmebaVision.CheckURL      = AmebaVision_CheckURL;	/* 対応するURLかどうかをチェックする */
AmebaVision.GetURL        = AmebaVision_GetURL;		/* ビデオのURLに変換する */
AmebaVision.Search        = AmebaVision_Search;		/* 動画サイトを検索する */

// 動画サイトリストへの登録
SiteList.push( AmebaVision );

(This post was last modified: 24/02/2008 11:41 AM by Chroma.)
24/02/2008 06:25 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Mc Cabe
Storm Trooper

Posts: 1,218.1771
Threads: 177
Joined: 14th Aug 2007
Reputation: 1.43435
E-Pigs: 38.5281
Offline
Post: #2
RE: PSPTube++ 200802224
Sweet! More stuff I don't understand lol

umm?
24/02/2008 09:25 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Chroma
Chromatic Nutjob

Posts: 2,626.3796
Threads: 435
Joined: 1st Mar 2007
Reputation: -5.01013
E-Pigs: 40.2135
Offline
Post: #3
RE: PSPTube++ 200802224
It's waaaaaay too long for the front page, so I added a spoiler.

PSN ID: Chroma3000
My Steam Page
ADD ME
superdouche Wrote:
TheGuy Wrote:
superdouche Wrote:You need at least an 8 inch penis, that's what I heard.
Man, if I had 8 inches, I would find a better use for it :P
Like what, pushing elevator buttons?
24/02/2008 11:41 AM
Visit this user's website Find all posts by this user Quote this message in a reply
roberth
Resident Full Stop Abuser.....

Posts: 4,580.2098
Threads: 200
Joined: 18th Jun 2007
Reputation: -5.5814
E-Pigs: 43.8419
Offline
Post: #4
RE: PSPTube++ 200802224
i understand the purpose i think, but that script is waaaaaay to complex for me to fanthom....particularly since most of it is showing up as question marks to me (don't think i have any characters beyond english installed on my PC)

(This post was last modified: 24/02/2008 03:00 PM by roberth.)
24/02/2008 02:59 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

 Quick Theme: