//D setting ver.1.000 [001]nicovideo2 [002]http://www.nicovideo.jp/watch/* [008]true [009]url=(.+)&title=.+ [010]$1 [012]true [013].+&title=(.+) [014]$1.flv [015]nop [016]auto [019]nop [024]true [025]Accept-Language=ja\n [028]true [029]nicovideo2_program1 [030]function nicovideo2_program1() {\n///////////////////////////////////////////////////////////////////////////////\n// 以下の行を各自の環境に合わせて書き換えてください。\n///////////////////////////////////////////////////////////////////////////////\n\n// cookie の取得方法を選択\n// 0: cookie を Internet Explorer から取得\n// (下にある「IE の cookie ファイルがあるフォルダ」「IE の cookie ファイルの名前」の設定が必要)\n// 1: cookie を Mozilla Firefox から取得\n// (下にある「Firefox の cookie ファイルがあるフォルダ」の設定が必要)\n\tstatic actmode = 0;\n\n// IE の cookie ファイルがあるフォルダ\n\tstatic ie_path = 'C:\\Documents and Settings\\(ユーザ名)\\Cookies\\';\n\n// IE の cookie ファイルの名前(ワイルドカード使用可)\n// 通常、Windows 2000/XP では書き換えなくても動作するはずです。\n\tstatic ie_name = '*nicovideo[*].txt';\n\n// Firefox の cookie ファイルがあるフォルダ\n\tstatic ff_path = 'C:\\Documents and Settings\\(ユーザ名)\\Application Data\\Mozilla\\Firefox\\Profiles\\(プロファイルフォルダ)\\';\n\n///////////////////////////////////////////////////////////////////////////////\n// 書き換え ここまで\n///////////////////////////////////////////////////////////////////////////////\n\n\tvar cookiestr = '';\n\tvar strs = new Strings;\n\tswitch (actmode) {\n\t\tcase 0:\n\t\t\tnicovideo2_debuginfo('動作モード:IE から cookie を取得');\n\t\t\tvar ie_dir = new Directory(ie_path);\n\t\t\tvar ie_cookie_name = ie_dir.findFirstFile(ie_name);\n\t\t\tif (ie_cookie_name == null) {\n\t\t\t\twriteln('nicovideo>IE の cookieファイルが見つかりません');\n\t\t\t\treturn '';\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tstrs.loadFromFile(ie_dir.includePathDelimiter() + ie_cookie_name);\n\t\t\t}\n\t\t\tcatch (e) {\n\t\t\t\twriteln('nicovideo>IE の cookie ファイルが読み込めません');\n\t\t\t}\n\t\t\tfor (var i in strs) {\n\t\t\t\tif (strs[i].match(/user_session_/g) != null) {\n\t\t\t\t\tcookiestr = 'user_session=' + strs[i] + ';';\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (cookiestr == '') {\n\t\t\t\twriteln('nicovideo>IE に cookie が保存されていません');\n\t\t\t\treturn '';\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tnicovideo2_debuginfo('動作モード:Firefox から cookie を取得');\n\t\t\tvar ff_dir = new Directory(ff_path);\n\t\t\tvar ff_cookie_name = ff_dir.findFirstFile('cookies.txt');\n\t\t\tif (ff_cookie_name == null) {\n\t\t\t\twriteln('nicovideo>Firefox の cookie ファイルが見つかりません');\n\t\t\t\treturn '';\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tstrs.loadFromFile(ff_dir.includePathDelimiter() + ff_cookie_name);\n\t\t\t}\n\t\t\tcatch (e) {\n\t\t\t\twriteln('nicovideo>Firefox の cookie ファイルが読み込めません');\n\t\t\t}\n\t\t\tfor (var i in strs) {\n\t\t\t\tif (strs[i].match(/\\.nicovideo\\.jp.*(user_session_.*)/g) != null) {\n\t\t\t\t\tcookiestr = 'user_session=' + RegExp.$1 + ';';\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (cookiestr == '') {\n\t\t\t\twriteln('nicovideo>Firefox に cookie が保存されていません');\n\t\t\t\treturn '';\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn '';\n\t}\n\tvar data = '';\n\tvar http = new HTTP;\n\thttp.debug = debug;\n\thttp.version = '1.1';\n\thttp.requestHeader['Cookie'] = cookiestr;\n\ttry {\n\t\tdata = http.get(u.url);\n\t}\n\tcatch (e) {\n\t\tnicovideo2_debugerr('http.get()に失敗しました');\n\t\treturn '';\n\t}\n\tif (http.responseHeader.code != 200) {\n\t\tnicovideo2_debugerr('視聴ページの取得に失敗しました');\n\t\treturn '';\n\t}\n\tif (data.match(/
/g) != null) {\n\t\tnicovideo2_debugerr('視聴ページが取得できません');\n\t\treturn '';\n\t}\n\tif (data.match(/

(.*)<\\/a><\\/h1>/g) == null) {\n\t\tnicovideo2_debugerr('タイトルが取得できません');\n\t\treturn '';\n\t}\n\tvar title = RegExp.$1.fromUTF8toSJIS();\n\tnicovideo2_debuginfo('タイトル:' + title);\n\tcookiestr += http.responseHeader.cookie.data;\n// ファイルの URL を取得\n\tu.url.match(/http.*?watch\\/(.*)/g);\n\tvar url = 'http://www.nicovideo.jp/getflv?v=' + RegExp.$1;\n\tdata = '';\n\thttp.requestHeader['Cookie'] = cookiestr;\n\ttry {\n\t\tdata = http.get(url);\n\t}\n\tcatch (e) {\n\t\treturn '';\n\t}\n\tif (http.responseHeader.code != 200) {\n\t\tnicovideo2_debugerr('動画の URL の取得に失敗しました');\n\t\treturn '';\n\t}\n\tif (data.match(/url=(.*)&link=/g) == null) {\n\t\tnicovideo2_debugerr('動画の URL が取得できません');\n\t\treturn '';\n\t}\n\turl = unescape(RegExp.$1);\n\tnicovideo2_debuginfo('ダウンロードする URL:' + url);\n\tif (url.match(/\\.nicovideo\\.jp/g) != null)\n\t\ttheHeaders['Cookie'] = cookiestr;\n\treturn 'url=' + url + '&title=' + title;\n}\n\nfunction nicovideo2_debugerr(str) {\n\tif (debug) {\n\t\twriteln('nicovideo_debugerr>' + str);\n\t}\n}\n\nfunction nicovideo2_debuginfo(str) {\n\tif (debug) {\n\t\twriteln('nicovideo_debuginfo>' + str);\n\t}\n}\n [036]true //end 使い方は readme.txt の設定データの更新を読んで下さい。