スクリプトにゃ
コツコツと考えてたにゃ、スクリプトですにゃ。
新しく覚えるのが嫌にゃので、なるべくC言語風にゃ感じで、あと、色々と扱いやすいようにゃにとかにゃってたらにゃ、結局にゃんきょく、無難にゃ感じにゃににゃってしまったですにゃ。
実装していくと、多分細かい部分がかわっちゃうんだろうけどにゃ、大体は固まったかにゃ〜〜。
さて、ガリガリにゃるかにゃ。
//------------------------------------------------------------------------------ // PSPTube Version 20071015 exp //------------------------------------------------------------------------------ // // このプログラムを使った事により生じた一切の事象に関して製作者は、 // 一切の責任を負わないものとします。 // 自己責任でご使用下さい。 // また、不具合に関して修正の義務を一切負わないものとします。 // // In regard to all problems that occur while using this program, the developer // does not take responsibility. // The user takes responsibility. // In addition, the developer it not obligated to fix any problems. void System() { //============================================================================== // サイトリストを設定します。 // 検索結果画面でSELECTボタンを押すと次のサイトに切り替わります。 // SiteList = "NicoNico"; //------------------------------------------------------------------------------ // CPUクロックを設定します。222と333が設定できます。 // 222 : CPUのクロックを222MHzに設定します // 333 : CPUのクロックを333MHzに設定します // // CPUClockは222MHzだと音ずれとバッファが足りなくなります。 // 333MHzにすると本体が壊れるかもしれませんが、ずれなくなります。 // 自己責任で設定してください // // // The CPU clock can be set to either 222 or 333. // 222: The clock of the CPU is set to 222MHz // 333: The clock of the CPU is set to 333MHz // If the CPU Clock is set to 222MHz, there is a sound gap and the buffer // becomes insufficient. You are responsible if you overclock your PSP // to 333 MHz. // CPUClock = 333; //------------------------------------------------------------------------------ // 検索結果にサムネイルを表示するかどうかを設定 // // 1 : 表示する サムネイルを表示すると検索が遅くなります。 // 0 : 表示しない // // Whether or not to display thumbnails in the search results // 1: Thumbnails are used (slows search down) // 0: No Thumbnails // thumbnail = 1; //------------------------------------------------------------------------------ // キャッシュを利用するかどうかを設定 // // 1 : 利用する サムネイル表示をファイルにキャッシュする // 0 : 利用しない // // Whether or not the cache is used // 1: The thumbnail display will utilize the cache // 0: The thumbnail display will not utilize the cache // cache = 1; //------------------------------------------------------------------------------ // VSync待ちをするかどうかを設定 // // 1 : する ティアリングが抑制されますが、映像と音声のズレが起きやすくなります // 0 : しない // // Whether or not to wait for VSync (vertical synchronization) // 1: Wait for VSync // 0: Do not Wait for VSync Vsync = 0; //------------------------------------------------------------------------------ // 動画のコメントで使用するフォントを設定 // // Unicodeに対応したTrueTypeなフォントが使用可能です。 // ファイルサイズは8MBぐらいまで(小さければ小さいほど良い) // // 例えば、みかちゃんフォントやWindowsで使われているフォントが使用できます。 // MessageFont = "font/msgothic.ttc"; } //============================================================================== // NicoNico //============================================================================== int NicoNico::Login( void ) { sys_status( "ニコニコ動画 ログイン中" ); pszIniFile = "niconico.ini"; lstIni = sys_lst_load( pszIniFile ); // コンフィグから設定を読み込む pszMail = lstIni->"mail"; pszPassword = lstIni->"password"; fSaveIni = 0; sys_wallpaper( "nico.jpg" ); // 壁紙設定 if(pszMail == "") { fSaveIni = 1; pszMail = dlg_osk( "mail" ); // メールアドレスを入力 if(pszMail == "") { return -1; } } if(pszPassword == "") { fSaveIni = 1; pszPassword = dlg_osk( "password" ); // パスワードを入力 if(pszPassword == "") { return -1; } } // サーバーに情報を送信(post)し、ログインする pszLoginURI = "https://secure.nicovideo.jp/secure/login?site=niconico"; lstLoginSend = { "mail", pszMail }, { "password", pszPassword }; lstCookie = {}; // 前の情報は覚えてなくても…いいよね? lstResult = http_post( pszLoginURI, lstLoginSend, lstCookie ); if(lstResult->"ret" != 200) { dlg_msg( "Login-Error:" & lstResult->"ret" ); return -1; } if(fSaveIni) { // メールアドレスとパスワードをiniファイルに記録 lstIni->"mail" = pszMail; lstIni->"password" = pszPassword; sys_lst_save( pszIniFile, lstIni ); } return 0; } list NicoNico::Search( list lstInfo ) { // 検索 nPage = lstInfo->"page"; pszTag = url_encode( lstInfo->"tag" ); pszSearchURI = "http://www.nicovideo.jp/tag/" & pszTag & "?page=" & nPage & "&sort=f&order=d"; lstHttp = http_get( pszSearchURI, lstCookie ); if(lstHttp->"ret" != 200) { dlg_msg( "Search-Error:" & lstHttp->"ret" ); return {}; } // 取得した結果を解析 pszSearchKey = "^<p><a\s+href\s*=\s*\"watch/(?<ID>sm\d*)\">\s*<img\s+alt\s*=\s*\"(?<TITLE>[^\"]*)\"\s+src=\"(?<THUMBNAIL>[^\"]*)\".*$\\n.*$\n</div>\r\n\r\n<p\sclass=\"TXT10\">\r\n<strong>(?<MINUTE>\d+)分(?<SECOND>\d+)秒</strong><br>\r\n再生:<strong>(?<VIEW>[\d|,]+)</strong><br>\r\nコメント:<strong>(?<COMMENT>[\d|,]+)</strong></p>\r\n\r\n</div>\r\n\r\n.*$\n.*$\n<p\sclass=\"[^\"]*\"*\s[^>]*>(?<CONTENTS>.*)</p>\r\n"; pszContents = reg( lstHttp->"contents", pszSearchKey ); lstResult = {}; // 検索結果リストをクリア while(pszContents != "") { lstTmp ={ { "ID", ID }, { "Title", TITLE }, { "Contents", CONTENTS }, { "Thumbnail", THUMBNAIL }, { "TimeMinute", MINUTE }, { "TimeSecond", SECOND }, { "View", VIEW }}; lstResult = lstResult, lstTmp; // 検索結果リストに追加 pszContents = reg( pszContents, pszSearchKey ); } return lstResult; } int NicoNico::Play( list lstInfo ) { pszVideoID = lstInfo->"ID"; pszURI = "http://www.nicovideo.jp/watch/" & pszVideoID; lstHttp = http_get_keep_connect( pszURI, lstCookie ); pszURI = "http://www.nicovideo.jp/api/getflv?v=" & pszVideoID; lstHttp = http_get_keep_connect( pszURI, lstCookie ); pszSearchKey = "(^url:(?<MOVURL>.*)\r\n)|(^ms:(?<MS>.*)\r\n)|(^thread_id:(?<TID>.*)\r\n)"; reg( lstHttp->"contents", pszSearchKey ); lstHttp = http_get_keep_connect( MS, lstCookie ); // メッセージを取得 lstParam = { "buffer", 20 }; // 高画質なムービーだったら低画質にする if(reg( MOVURL, "low" ) == "") { MOVURL = MOVURL & "low"; } play_keep_connect( MOVURL, lstCookie, lstParam ); // ムービー再生 return 0; } //============================================================================== // test //============================================================================== // This is used to debug. void test() { //play( "test.flv" ); //play( "http://test.flv" ); }