(\d+)<\/span>/i;
47 |
48 | /**
49 | * マイリストの取得結果の中からサムネイル画像のURLを抽出する正規表現です。
50 | */
51 | public static var myListThumbImgUrlPattern: RegExp
52 | = /src="(https?:\/\/(?:tn[.-]|nicovideo\.cdn\.nimg\.jp\/thumbnails\/)[^"]*)"/;
53 |
54 | /**
55 | * マイリストの取得結果の中からメモを抽出する正規表現です。
56 | */
57 | public static var myListMemoPattern: RegExp = /([^<]*)<\/p>/;
58 |
59 | /**
60 | * マイリストの取得結果の中から投稿日を抽出する正規表現です
61 | * 2008年09月03日 19:35:42
62 | */
63 | public static var myListInfoDate: RegExp = /([^<]+)<\/strong>/;
64 |
65 | /**
66 | * マイリストの取得結果の中から動画の再生時間を抽出する正規表現です。
67 | * 5:39
68 | */
69 | public static var myListLength: RegExp = /([^<]+)<\/strong>/;
70 |
71 |
72 | public function NicoPattern() {
73 | /* nothing */
74 | }
75 |
76 | }
77 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/util/NumberUtil.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.util {
2 | public class NumberUtil {
3 | public function NumberUtil() {
4 | }
5 |
6 | /**
7 | * 渡された数字に3桁ごとのカンマを追加します。
8 | * @param str
9 | * @return
10 | *
11 | */
12 | public static function addComma(str: String): String {
13 |
14 | var len: int = str.length;
15 |
16 | for (var i: int = 1; i < len; i++) {
17 | var index: int = i * (-3) - (i - 1);
18 | var b: String = str.substring(0, len + index);
19 | var a: String = str.substring(len + index);
20 | if (b.length == 0) {
21 | break;
22 | }
23 | str = b + "," + a;
24 | len++;
25 | }
26 |
27 | return str;
28 |
29 | }
30 |
31 | }
32 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/util/RankingStringBuilder.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.util {
2 | import org.mineap.nndd.LogManager;
3 |
4 | public class RankingStringBuilder {
5 | public function RankingStringBuilder(logManager: LogManager) {
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/util/RelationTypeUtil.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.util {
2 | import org.mineap.nicovideo4as.model.RelationOrderType;
3 | import org.mineap.nicovideo4as.model.RelationSortType;
4 |
5 | /**
6 | *
7 | * @author shiraminekeisuke
8 | *
9 | */
10 | public class RelationTypeUtil {
11 | public function RelationTypeUtil() {
12 | }
13 |
14 | public static function convertRelationSortType(index: int): String {
15 | switch (index) {
16 | case 0:
17 | return RelationSortType.POPULAR;
18 | case 1:
19 | return RelationSortType.RESPONSE_COUNT;
20 | case 2:
21 | return RelationSortType.VIEW_COUNT;
22 | case 3:
23 | return RelationSortType.F;
24 | default:
25 | return RelationSortType.POPULAR;
26 | }
27 | }
28 |
29 | public static function convertRelationOrderType(index: int): String {
30 | switch (index) {
31 | case 0:
32 | return RelationOrderType.DESCENDING;
33 | case 1:
34 | return RelationOrderType.ASCENDING;
35 | default:
36 | return RelationOrderType.DESCENDING;
37 | }
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/util/ShortUrlChecker.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.util {
2 | import flash.events.HTTPStatusEvent;
3 | import flash.net.URLLoader;
4 | import flash.net.URLRequest;
5 |
6 | /**
7 | *
8 | * @author mine
9 | *
10 | */
11 | public class ShortUrlChecker extends URLLoader {
12 |
13 | private var _url: String = null;
14 |
15 | public var shortUrls: Vector. = Vector.(["http://nico.ms", "http://bit.ly", "http://t.co"]);
16 |
17 | public function ShortUrlChecker(urlRequest: URLRequest = null) {
18 | super(urlRequest);
19 | }
20 |
21 | /**
22 | *
23 | * @return
24 | *
25 | */
26 | public function get url(): String {
27 | return _url;
28 | }
29 |
30 | /**
31 | *
32 | * @param url
33 | * @return
34 | *
35 | */
36 | public function isShortUrl(url: String): Boolean {
37 |
38 | for each(var str: String in shortUrls) {
39 | var i: int = url.indexOf(str);
40 | if (i != -1) {
41 | return true;
42 | }
43 | }
44 |
45 | return false;
46 | }
47 |
48 | /**
49 | *
50 | * @param url
51 | *
52 | */
53 | public function expansion(url: String): void {
54 |
55 | var request: URLRequest = new URLRequest(url);
56 | this.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, function (event: HTTPStatusEvent): void {
57 | _url = event.responseURL;
58 | });
59 | this.load(request);
60 | }
61 |
62 | }
63 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/util/ThumbInfoUtil.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.util {
2 | import org.mineap.nicovideo4as.util.VideoTypeUtil;
3 |
4 | /**
5 | *
6 | *
7 | * @author shiraminekeisuke(MineAP)
8 | *
9 | */
10 | public class ThumbInfoUtil {
11 | public function ThumbInfoUtil() {
12 | }
13 |
14 | /**
15 | * 渡されたStringのマイリストID、ユーザーID、動画IDをNNDD用のHTML表現に置き換えて返します。
16 | * @param text
17 | * @return
18 | *
19 | */
20 | public static function encodeThumbInfo(text: String): String {
21 |
22 | var myLists: Array = [];
23 | // TODO: Better replacement
24 | // var linkPattern: RegExp = new RegExp(
25 | // "<(?i:a)(?:\\s+[^\\s\"'>/=]+(?:\\s*=\\s*(?:[^\\s\"'=><`]+|'[^']*'|\"[^\"]*\"))?)*" +
26 | // "(?:\\s+(?i:href)\\s*=\\s*([^\\s\"'=><`]+|'[^']*'|\"[^\"]*\"))" +
27 | // "(?:\\s+[^\\s\"'>/=]+(?:\\s*=\\s*(?:[^\\s\"'=><`]+|'[^']*'|\"[^\"]*\"))?)*>.+?(?i:a)>",
28 | // "g"
29 | // );
30 | //
31 |
32 | var patterns: Array = [];
33 | patterns.push(new RegExp("https?://www\\.nicovideo\\.jp/(mylist/[1-9][0-9]*)"));
34 | patterns.push(new RegExp("https?://www\\.nicovideo\\.jp/(user/[1-9][0-9]*)"));
35 | patterns.push(new RegExp("https?://ch\\.nicovideo\\.jp/(channel/ch[^\"]+)"));
36 | patterns.push(new RegExp("https?://com\\.nicovideo\\.jp/(community/co[^\"]+)"));
37 |
38 | var video_pattern: RegExp = new RegExp("https?://www\\.nicovideo\\.jp/watch/([^\"]+)");
39 |
40 | var fontsize_pattern: RegExp = new RegExp("size=\"(\\d+)\"", "ig");
41 |
42 | // 小さすぎるサイズを全置換
43 | text = text.replace(fontsize_pattern, function (): String {
44 | var str: String = arguments[0];
45 | if (arguments.length > 1 && arguments[1] != "") {
46 | var size: int = int(arguments[1]);
47 | if (size < 10) {
48 | size = size + 8;
49 | str = String(size);
50 | }
51 | }
52 | return "size=\"" + size + "\"";
53 | });
54 |
55 | var returnString: String = text;
56 | returnString = returnString.replace(/<(?i:a\s+href)="([^"]+)"[^>]*?>.*?<\/(?i:a)>/g, function (): String {
57 | var url: String = arguments[1];
58 | var matches: Array = null;
59 | for each(var pattern: RegExp in patterns) {
60 | matches = matches || url.match(pattern);
61 | if (matches) {
62 | myLists.push(matches[1]);
63 | return "" + matches[1] + "";
64 | }
65 | }
66 |
67 | if (matches = url.match(video_pattern)) {
68 | var videoId: String = matches[1];
69 | return "" + videoId + "";
70 | }
71 |
72 | return arguments[0];
73 | });
74 |
75 | return returnString;
76 | }
77 |
78 |
79 | }
80 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/util/TreeDataBuilder.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.util {
2 | import org.mineap.nndd.model.tree.TreeFileItem;
3 | import org.mineap.nndd.model.tree.TreeFolderItem;
4 |
5 | /**
6 | *
7 | * Treeコントロールに渡すObject型のデータを構築するクラスです。
8 | *
9 | * @author shiraminekeisuke
10 | *
11 | */
12 | public class TreeDataBuilder {
13 |
14 | /**
15 | * コンストラクタ
16 | *
17 | */
18 | public function TreeDataBuilder() {
19 | }
20 |
21 | /**
22 | * フォルダオブジェクトを生成します。フォルダオブジェクトは、String型の値を保持するlabelプロパティと、
23 | * 子にフォルダオブジェクトとファイルオブジェクトを格納するためのArray型のchildrenプロパティを持ちます。
24 | *
25 | * @param folderName
26 | * @return
27 | *
28 | */
29 | public function getFolderObject(folderName: String): TreeFolderItem {
30 | var object: TreeFolderItem = new TreeFolderItem();
31 | object.label = folderName;
32 | object.children = new Array();
33 | return object;
34 | }
35 |
36 | /**
37 | * ファイルオブジェクトを生成します。ファイルオブジェクトはString型の値を保持するlabelプロパティを持っています。
38 | *
39 | * @param fileName
40 | * @return
41 | *
42 | */
43 | public function getFileObject(fileName: String): TreeFileItem {
44 | var object: TreeFileItem = new TreeFileItem();
45 | object.label = fileName;
46 | return object;
47 | }
48 |
49 | /**
50 | * 渡されたfolderObjectから、removeNameArrayで指定された名前と同じ名前をlabelプロパティ持つオブジェクトを削除します。
51 | *
52 | * @param folderObject
53 | * @param removeNameArray
54 | * @return
55 | *
56 | */
57 | public function removeChildrenFromFolderObject(folderObject: Object, removeNameArray: Array): Object {
58 | var array: Array = folderObject.children;
59 |
60 | for (var i: int = 0; i < array.length; i++) {
61 | for (var j: int = 0; j < removeNameArray.length; j++) {
62 | if (array[i].label == removeNameArray[j]) {
63 | array.splice(i, 1);
64 | break;
65 | }
66 | }
67 | }
68 |
69 | folderObject.children = array;
70 |
71 | return folderObject;
72 | }
73 |
74 | }
75 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/util/TreeItemUtil.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.util {
2 | import mx.controls.Tree;
3 |
4 | import org.mineap.nndd.model.tree.ITreeItem;
5 | import org.mineap.nndd.model.tree.TreeFolderItem;
6 |
7 | public class TreeItemUtil {
8 | public function TreeItemUtil() {
9 | }
10 |
11 | public static function treeOpenItemArrayCreate(treeItem: ITreeItem, tree: Tree): Array {
12 |
13 | var array: Array = new Array();
14 |
15 | if (tree.openItems == null) {
16 | return array;
17 | }
18 |
19 | if (!(tree.openItems as Array).indexOf(treeItem)) {
20 | return array;
21 | }
22 |
23 | var folderItem: TreeFolderItem = null;
24 | if (treeItem is TreeFolderItem) {
25 | folderItem = (treeItem as TreeFolderItem);
26 | } else {
27 | return array;
28 | }
29 |
30 | for each(var item: ITreeItem in folderItem.children) {
31 | var tempArray: Array = treeOpenItemArrayCreate(item, tree);
32 |
33 | for each(var item2: ITreeItem in tempArray) {
34 | array.push(item2);
35 | }
36 | }
37 |
38 | return array;
39 | }
40 |
41 | }
42 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/util/VideoPrefix.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.util {
2 | public class VideoPrefix {
3 |
4 | /* ユーザー投稿 */
5 | public static const sm: VideoPrefix = new VideoPrefix("sm");
6 |
7 | public static const nm: VideoPrefix = new VideoPrefix("nm");
8 |
9 | public static const am: VideoPrefix = new VideoPrefix("am");
10 |
11 | public static const fz: VideoPrefix = new VideoPrefix("fz");
12 |
13 | public static const ut: VideoPrefix = new VideoPrefix("ut");
14 |
15 |
16 | /* 公式 */
17 | public static const ax: VideoPrefix = new VideoPrefix("ax");
18 |
19 | public static const ca: VideoPrefix = new VideoPrefix("ca");
20 |
21 | public static const cd: VideoPrefix = new VideoPrefix("cd");
22 |
23 | public static const cw: VideoPrefix = new VideoPrefix("cw");
24 |
25 | public static const fx: VideoPrefix = new VideoPrefix("fx");
26 |
27 | public static const ig: VideoPrefix = new VideoPrefix("ig");
28 |
29 | public static const na: VideoPrefix = new VideoPrefix("na");
30 |
31 | public static const nl: VideoPrefix = new VideoPrefix("nl");
32 |
33 | public static const om: VideoPrefix = new VideoPrefix("om");
34 |
35 | public static const sd: VideoPrefix = new VideoPrefix("sd");
36 |
37 | public static const sk: VideoPrefix = new VideoPrefix("sk");
38 |
39 | public static const yk: VideoPrefix = new VideoPrefix("yk");
40 |
41 | public static const yo: VideoPrefix = new VideoPrefix("yo");
42 |
43 | public static const za: VideoPrefix = new VideoPrefix("za");
44 |
45 | public static const zb: VideoPrefix = new VideoPrefix("zb");
46 |
47 | public static const zc: VideoPrefix = new VideoPrefix("zc");
48 |
49 | public static const zd: VideoPrefix = new VideoPrefix("zd");
50 |
51 | public static const ze: VideoPrefix = new VideoPrefix("ze");
52 |
53 | /* 公式動画全般 */
54 | public static const so: VideoPrefix = new VideoPrefix("so");
55 |
56 |
57 | public static const PREFIX_ARRAY: Array = new Array(
58 | sm,
59 | nm,
60 | am,
61 | fz,
62 | ut,
63 | ax,
64 | ca,
65 | cd,
66 | cw,
67 | fx,
68 | ig,
69 | na,
70 | nl,
71 | om,
72 | sd,
73 | sk,
74 | yk,
75 | yo,
76 | za,
77 | zb,
78 | zc,
79 | zd,
80 | ze,
81 | so
82 | );
83 |
84 |
85 | public var prefix: String = "sm";
86 |
87 | public function VideoPrefix(prefix: String) {
88 | this.prefix = prefix;
89 | }
90 | }
91 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/util/WebServiceAccessUtil.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.util {
2 | import flash.events.Event;
3 | import flash.net.URLRequest;
4 | import flash.net.URLVariables;
5 | import flash.net.navigateToURL;
6 |
7 | import mx.controls.Alert;
8 | import mx.core.FlexGlobals;
9 |
10 | import org.mineap.nicovideo4as.WatchVideoPage;
11 | import org.mineap.nndd.LogManager;
12 |
13 | /**
14 | * ニコニコ動画以外のウェブサービスへのアクセスを行うユーティリティクラスです
15 | *
16 | * @author shiraminekeisuke(MineAP)
17 | *
18 | */
19 | public class WebServiceAccessUtil {
20 | public function WebServiceAccessUtil() {
21 | }
22 |
23 | public static function openNiconicoDougaForVideo(videoId: String): void {
24 | var url: String = null;
25 | if (videoId != null) {
26 | url = WatchVideoPage.WATCH_VIDEO_PAGE_URL + videoId;
27 | navigateToURL(new URLRequest(url));
28 | LogManager.instance.addLog("ウェブブラウザで開く:" + url);
29 | }
30 | }
31 |
32 | /**
33 | *
34 | * @return
35 | *
36 | */
37 | public static function openNicoSound(videoId: String): void {
38 | var watch: WatchVideoPage = new WatchVideoPage();
39 | watch.addEventListener(WatchVideoPage.WATCH_SUCCESS, function (event: Event): void {
40 | var url: String = watch.audioDownloadUrl;
41 |
42 | if (url == null) {
43 | Alert.show("この動画はNicoSoundでダウンロードできません。", "情報");
44 | FlexGlobals.topLevelApplication.activate();
45 | LogManager.instance.addLog("この動画はNicoSoundに非対応:" + videoId);
46 | } else {
47 | navigateToURL(new URLRequest(url));
48 | LogManager.instance.addLog("NicoSoundで開く:" + url);
49 | }
50 |
51 | });
52 | watch.addEventListener(WatchVideoPage.WATCH_FAIL, function (event: Event): void {
53 | Alert.show("ダウンロードページを開けませんでした。\n" + event, "エラー");
54 | FlexGlobals.topLevelApplication.activate();
55 | LogManager.instance.addLog("NicoSoundで開くのに失敗:" + event);
56 | });
57 | watch.watchVideo(videoId, true);
58 |
59 | }
60 |
61 | /**
62 | *
63 | * @param videoId
64 | * @param title
65 | *
66 | */
67 | public static function addHatenaBookmark(videoId: String, title: String): void {
68 | var url: String = null;
69 |
70 | if (videoId != null) {
71 | url = "http://www.nicovideo.jp/watch/" + videoId;
72 | navigateToURL(new URLRequest("http://b.hatena.ne.jp/add?mode=confirm&is_bm=1&title=" +
73 | encodeURIComponent(title) + "&url=" + url));
74 | LogManager.instance.addLog("はてなダイアリーに登録:" + title + ":" + url);
75 | }
76 | }
77 |
78 | /**
79 | *
80 | * @param videoId
81 | * @param title
82 | *
83 | */
84 | public static function tweet(videoId: String, title: String): void {
85 | var tweet: String = "";
86 | var url: String = "";
87 |
88 | if (videoId != null) {
89 | url = "http://nico.ms/" + videoId + " #nicovideo #nndd #" + videoId;
90 |
91 | var index: int = title.indexOf("- [");
92 | if (index > 0) {
93 | title = title.substr(0, index);
94 | }
95 |
96 | tweet = title + " " + url;
97 |
98 | var urlRequest: URLRequest = new URLRequest("https://twitter.com/");
99 | var variables: URLVariables = new URLVariables();
100 | variables.status = tweet;
101 |
102 | urlRequest.data = variables;
103 |
104 | navigateToURL(urlRequest);
105 | LogManager.instance.addLog("twitterでつぶやく:" + title);
106 | }
107 | }
108 |
109 | }
110 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/versionCheck/IVersionChecker.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.versionCheck {
2 | public interface IVersionChecker {
3 |
4 | function init(checkOnInit: Boolean): void;
5 |
6 | function checkUpdate(isCheckForUpdate: Boolean = false): void;
7 |
8 | }
9 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/versionCheck/VersionChecker.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.versionCheck {
2 | import air.update.ApplicationUpdaterUI;
3 | import air.update.events.DownloadErrorEvent;
4 | import air.update.events.StatusFileUpdateErrorEvent;
5 | import air.update.events.StatusUpdateErrorEvent;
6 | import air.update.events.UpdateEvent;
7 |
8 | import flash.events.ErrorEvent;
9 | import flash.filesystem.File;
10 |
11 | import org.mineap.nndd.LogManager;
12 |
13 | /**
14 | * NNDDのバージョンチェックを行うクラスです。
15 | *
16 | * @author shiraminekeisuke
17 | *
18 | */
19 | public class VersionChecker implements IVersionChecker {
20 |
21 | private static const checker: VersionChecker = new VersionChecker();
22 |
23 | private var updater: ApplicationUpdaterUI = new ApplicationUpdaterUI();
24 |
25 | private var checkOnInit: Boolean = false;
26 |
27 | /**
28 | * VersionCheckerの唯一のインスタンスを取得します
29 | *
30 | * @return
31 | *
32 | */
33 | public static function get instance(): VersionChecker {
34 | return checker;
35 | }
36 |
37 | public function VersionChecker() {
38 | if (checker != null) {
39 | throw ArgumentError("VersionCheckerはインスタンス化できません。");
40 | }
41 | }
42 |
43 | /**
44 | * 初期化処理。
45 | * @param checkOnInit
46 | *
47 | */
48 | public function init(checkOnInit: Boolean): void {
49 | this.checkOnInit = checkOnInit;
50 |
51 | updater.configurationFile = new File("app:/config/updateConfig.xml");
52 | updater.addEventListener(UpdateEvent.INITIALIZED, updaterInitializedEventHandler);
53 | updater.addEventListener(DownloadErrorEvent.DOWNLOAD_ERROR, updaterDownloadErrorEventHandler);
54 | updater.addEventListener(ErrorEvent.ERROR, updaterErrorEventHandler);
55 | updater.addEventListener(StatusFileUpdateErrorEvent.FILE_UPDATE_ERROR, updaterErrorEventHandler);
56 | updater.addEventListener(StatusUpdateErrorEvent.UPDATE_ERROR, updaterErrorEventHandler);
57 | updater.initialize();
58 |
59 | }
60 |
61 | private function updaterErrorEventHandler(event: ErrorEvent): void {
62 | trace(event);
63 | }
64 |
65 | private function updaterDownloadErrorEventHandler(event: DownloadErrorEvent): void {
66 | trace(event);
67 | }
68 |
69 | private function updaterInitializedEventHandler(event: UpdateEvent): void {
70 | if (this.checkOnInit) {
71 | this.checkUpdate();
72 | }
73 | }
74 |
75 | /**
76 | * バージョンチェックを行います。
77 | *
78 | * @param isCheckForUpdate アップデート確認前メッセージを表示するかどうか。デフォルトはfalseで表示しない。
79 | *
80 | */
81 | public function checkUpdate(isCheckForUpdate: Boolean = false): void {
82 | LogManager.instance.addLog("バージョンチェック(currentVersion:" + updater.currentVersion + ")");
83 | updater.isCheckForUpdateVisible = isCheckForUpdate;
84 | updater.checkNow();
85 |
86 | }
87 |
88 | }
89 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/versionCheck/VersionCheckerFactory.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.versionCheck {
2 | import flash.desktop.NativeProcess;
3 |
4 | /**
5 | *
6 | * @author shiraminekeisuke(MineAP)
7 | *
8 | */
9 | public class VersionCheckerFactory {
10 | public function VersionCheckerFactory() {
11 | // nothing
12 | }
13 |
14 | /**
15 | * IVersionCheckerのインスタンスを生成して返します。
16 | *
17 | * @return
18 | *
19 | */
20 | public static function create(): IVersionChecker {
21 |
22 | if (NativeProcess.isSupported) {
23 | // ネイティブプロセス用
24 | return VersionCheckerForNativeApplication.instance;
25 | } else {
26 | // AIR用
27 | return VersionChecker.instance;
28 | }
29 |
30 |
31 | }
32 |
33 | }
34 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/versionCheck/VersionCheckerForNativeApplication.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.versionCheck {
2 | import flash.events.TimerEvent;
3 | import flash.utils.Timer;
4 |
5 | /**
6 | * NNDDのバージョンチェックを行うクラスです。(ネイティブインストーラ用)
7 | *
8 | * @author shiraminekeisuke(MineAP)
9 | *
10 | */
11 | public class VersionCheckerForNativeApplication implements IVersionChecker {
12 |
13 | private var updater: NNDDUpdaterWindow = null;
14 |
15 | private var checkOnInit: Boolean = false;
16 |
17 | private static const checker: VersionCheckerForNativeApplication = new VersionCheckerForNativeApplication();
18 |
19 | /**
20 | *
21 | * @return
22 | *
23 | */
24 | public static function get instance(): VersionCheckerForNativeApplication {
25 | return checker;
26 | }
27 |
28 | public function VersionCheckerForNativeApplication() {
29 | if (checker != null) {
30 | throw new ArgumentError("VersionCheckerForNativeApplicationクラスはインスタンス化できません。");
31 | }
32 | }
33 |
34 | /**
35 | *
36 | * @param checkOnInit
37 | *
38 | */
39 | public function init(checkOnInit: Boolean): void {
40 | this.checkOnInit = checkOnInit;
41 |
42 | if (checkOnInit) {
43 | this.updater = new NNDDUpdaterWindow();
44 | this.updater.isAutoCheck = true;
45 | this.updater.open();
46 | }
47 |
48 | timerStart();
49 | }
50 |
51 | private function timerStart(): void {
52 | var timer: Timer = new Timer(1000 * 60 * 60 * 24, 1);
53 | timer.addEventListener(TimerEvent.TIMER_COMPLETE, function (event: TimerEvent): void {
54 | try {
55 | checkUpdate(false);
56 | } catch (error: Error) {
57 |
58 | }
59 | timerStart();
60 | });
61 | timer.start();
62 | }
63 |
64 | /**
65 | *
66 | * @param isCheckForUpdate
67 | *
68 | */
69 | public function checkUpdate(isCheckForUpdate: Boolean = false): void {
70 | if (updater != null) {
71 | if (!updater.closed) {
72 | updater.close();
73 | }
74 | updater = null;
75 | }
76 |
77 | this.updater = new NNDDUpdaterWindow();
78 | this.updater.isAutoCheck = !isCheckForUpdate;
79 | this.updater.open();
80 | }
81 | }
82 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/versionCheck/VersionUtil.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.versionCheck {
2 | import flash.desktop.NativeApplication;
3 |
4 | /**
5 | *
6 | * @author shiraminekeisuke
7 | *
8 | */
9 | public class VersionUtil {
10 |
11 | private static const _versionUtil: VersionUtil = new VersionUtil();
12 |
13 | /**
14 | *
15 | * @return
16 | *
17 | */
18 | public static function get instance(): VersionUtil {
19 | return _versionUtil;
20 | }
21 |
22 | public function VersionUtil() {
23 | }
24 |
25 | /**
26 | *
27 | * @return 2.x.x
28 | *
29 | */
30 | public function get versionNumber(): String {
31 | var appXML: XML = NativeApplication.nativeApplication.applicationDescriptor;
32 | var air: Namespace = appXML.namespaceDeclarations()[0];
33 | var version: String = appXML.air::versionNumber;
34 | return version;
35 | }
36 |
37 | /**
38 | *
39 | * @return 2.x.x (Beta)
40 | *
41 | */
42 | public function get versionLabel(): String {
43 | var appXML: XML = NativeApplication.nativeApplication.applicationDescriptor;
44 | var air: Namespace = appXML.namespaceDeclarations()[0];
45 | var version: String = appXML.air::versionLabel;
46 | version = version.substring(1);
47 | return version;
48 | }
49 |
50 |
51 | }
52 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/view/NNDDText.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.view {
2 | import flash.events.MouseEvent;
3 |
4 | import mx.controls.Text;
5 | import mx.core.FlexGlobals;
6 |
7 | import org.mineap.nndd.player.comment.Command;
8 |
9 | /**
10 | * NNDDText.as
11 | *
12 | * Copyright (c) 2009 MAP - MineApplicationProject. All Rights Reserved.
13 | *
14 | * @author shiraminekeisuke
15 | *
16 | */
17 | public class NNDDText extends Text {
18 |
19 | /**
20 | * このNNDDTextを表示するタイミングを決定するVposです。
21 | */
22 | public var vpos: Number = -1;
23 |
24 | /**
25 | * このNNDDTextを表示する際にフォントの大きさを決定するコマンドです。
26 | */
27 | public var size: int = Command.MEDIUM;
28 |
29 | /**
30 | * このNNDDTextを表示する際に表示位置を決定するコマンド(NAKA,UE,SHITA)です。
31 | */
32 | public var pos: int = Command.NAKA;
33 |
34 | /**
35 | * このNNDDTextに対応するコメントを投稿したユーザーのIDです
36 | */
37 | public var user_id: String = "";
38 |
39 | /**
40 | * このNNDDTextに対応するコメントを識別するための番号です。これはひとつの動画内では一意です。
41 | */
42 | public var no: Number = 0;
43 |
44 | /**
45 | * このNNDDTextに対応する修飾命令です
46 | */
47 | public var mail: String = "";
48 |
49 | /**
50 | * このNNDDTextの表示位置を決定する際に必要になるNNDDTextへの参照です。
51 | */
52 | public var nnddText: NNDDText = null;
53 |
54 | /**
55 | *
56 | *
57 | */
58 | public function NNDDText() {
59 | super();
60 | this.focusEnabled = true;
61 | this.selectable = false;
62 |
63 | // addEventListener(MouseEvent.CLICK, mouseClickEventHandler);
64 | addEventListener(MouseEvent.MOUSE_OVER, mouseOverEventHandler);
65 | addEventListener(MouseEvent.MOUSE_OUT, mouseOutEventHandler);
66 | }
67 |
68 | /**
69 | *
70 | * @param event
71 | *
72 | */
73 | private function mouseOverEventHandler(event: MouseEvent): void {
74 | if (!FlexGlobals.topLevelApplication.isMouseHide) {
75 | (event.currentTarget as NNDDText).drawFocus(true);
76 | }
77 | }
78 |
79 | /**
80 | *
81 | * @param event
82 | *
83 | */
84 | private function mouseOutEventHandler(event: MouseEvent): void {
85 | (event.currentTarget as NNDDText).drawFocus(false);
86 | }
87 |
88 | // /**
89 | // *
90 | // * @param event
91 | // *
92 | // */
93 | // private function mouseClickEventHandler(event:MouseEvent):void{
94 | // this.setFocus();
95 | // }
96 |
97 |
98 | }
99 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/view/SmoothImage.as:
--------------------------------------------------------------------------------
1 | package org.mineap.nndd.view {
2 | import flash.display.Bitmap;
3 | import flash.display.Loader;
4 | import flash.events.Event;
5 |
6 | import mx.controls.Image;
7 | import mx.core.mx_internal;
8 |
9 | use namespace mx_internal;
10 |
11 | /**
12 | *
13 | * @author shiraminekeisuke
14 | *
15 | */
16 | public class SmoothImage extends Image {
17 | /**
18 | *
19 | *
20 | */
21 | public function SmoothImage() {
22 | super();
23 | }
24 |
25 | /**
26 | * @private
27 | */
28 | override mx_internal function contentLoaderInfo_completeEventHandler(event: Event): void {
29 | var smoothLoader: Loader = event.target.loader as Loader;
30 | var smoothImage: Bitmap = smoothLoader.content as Bitmap;
31 | smoothImage.smoothing = true;
32 |
33 | super.contentLoaderInfo_completeEventHandler(event);
34 | }
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/src/org/mineap/nndd/view/UpdateDialog.as:
--------------------------------------------------------------------------------
1 | // ActionScript file
2 | import flash.events.Event;
3 | import flash.events.MouseEvent;
4 | import flash.net.URLRequest;
5 | import flash.net.navigateToURL;
6 |
7 | import mx.core.Application;
8 |
9 | public static const UPDATE_DIALOG_CLOSE: String = "UpdateDialogClose";
10 |
11 | private function okButtonClicked(event: MouseEvent): void {
12 | dispatchEvent(new Event(UPDATE_DIALOG_CLOSE));
13 | }
14 |
15 | private function goToDownload(): void {
16 |
17 | var urlRequest: URLRequest = new URLRequest("https://github.com/nndd-reboot/NNDD");
18 | urlRequest.userAgent = "NNDD " + Application.application.version;
19 |
20 | navigateToURL(urlRequest);
21 | dispatchEvent(new Event(UPDATE_DIALOG_CLOSE));
22 | }
23 |
--------------------------------------------------------------------------------
/src/org/mineap/util/config/ConfUtil.as:
--------------------------------------------------------------------------------
1 | package org.mineap.util.config {
2 | import flash.errors.IOError;
3 | import flash.filesystem.File;
4 | import flash.system.Capabilities;
5 |
6 | public class ConfUtil {
7 | public function ConfUtil() {
8 | }
9 |
10 |
11 | /**
12 | *
13 | * @param value
14 | * @return
15 | *
16 | */
17 | public static function parseBoolean(value: Object): Boolean {
18 |
19 | if (value == null) {
20 | return false;
21 | }
22 |
23 | if (value is Boolean) {
24 | return Boolean(value);
25 | }
26 |
27 | if (value is String) {
28 | if (String(value).toLowerCase() == "false") {
29 | return false;
30 | } else {
31 | return true;
32 | }
33 | }
34 |
35 | return Boolean(value);
36 |
37 | }
38 |
39 |
40 | /**
41 | * AIR3.2世代のアプリケーションストレージにある設定ファイルを、AIR3.3世代のアプリケーションストレージにコピーします。
42 | */
43 | public static function movePrefToAppSupport(): void {
44 |
45 | if (Capabilities.os.toLowerCase().indexOf("mac") != -1 &&
46 | File.applicationStorageDirectory.getDirectoryListing().length == 0) {
47 |
48 | // AIR3.2以前
49 | var oldDir: File = File.userDirectory.resolvePath("Library/Preferences/org.mineap.nndd/Local Store/");
50 |
51 | if (!oldDir.exists) {
52 | return;
53 | }
54 |
55 | // AIR3.3以降
56 | var newDir: File = File.applicationStorageDirectory;
57 |
58 | for each(var oldFile: File in oldDir.getDirectoryListing()) {
59 | try {
60 | oldFile.copyTo(newDir.resolvePath(oldFile.name), false);
61 | } catch (e: IOError) {
62 | trace(e);
63 | }
64 | }
65 | }
66 |
67 | }
68 |
69 | }
70 | }
--------------------------------------------------------------------------------
/src/org/mineap/util/config/ConfigManager.as:
--------------------------------------------------------------------------------
1 | package org.mineap.util.config {
2 | import flash.filesystem.File;
3 |
4 | /**
5 | * 設定情報を管理するクラスです
6 | *
7 | * @author shiraminekeisuke(MineAP)
8 | *
9 | */
10 | public class ConfigManager {
11 |
12 | /**
13 | * 唯一の ConfigManager インスタンス
14 | */
15 | private static const _configManager: ConfigManager = new ConfigManager();
16 |
17 | /**
18 | * 設定のIOを担当する ConfigIO のインスタンス
19 | */
20 | private var _configIO: ConfigIO;
21 |
22 | /**
23 | * 値をキーに結びつけてマッピングして保持するオブジェクト
24 | */
25 | private var _map: Object = new Object();
26 |
27 | /**
28 | * 唯一の ConfigManager を返します。
29 | * @return
30 | *
31 | */
32 | public static function getInstance(): ConfigManager {
33 | return _configManager;
34 | }
35 |
36 | /**
37 | * コンストラクタ
38 | * このクラスはシングルトンです。 ConfigManager#getInstance() を使ってインスタンスを取得してください。
39 | */
40 | public function ConfigManager() {
41 | this._configIO = ConfigIO.getInstance();
42 | this.reload();
43 | }
44 |
45 | /**
46 | * 設定を保存します
47 | *
48 | */
49 | public function save(): void {
50 |
51 | this._configIO.clearOnMemory();
52 |
53 | for (var key: String in this._map) {
54 | var value: String = this._map[key];
55 | if (value != null) {
56 | this._configIO.setValue(key, value);
57 | }
58 | }
59 |
60 | this._configIO.save();
61 |
62 | this.reload();
63 |
64 | }
65 |
66 | /**
67 | * ConfigManagerが保持する設定をリセットし、再度読み込みます。
68 | * 設定ファイルが存在しないときは false を返します。
69 | *
70 | * @return
71 | */
72 | public function reload(): Boolean {
73 |
74 | this._map = new Object();
75 |
76 | if (this._configIO.load()) {
77 |
78 | var names: Vector. = this._configIO.getNames();
79 |
80 | for each(var name: String in names) {
81 | this._map[name] = this._configIO.getByName(name);
82 | }
83 |
84 | return true;
85 |
86 | } else {
87 | return false;
88 | }
89 | }
90 |
91 | /**
92 | *
93 | * @param name
94 | * @param value
95 | *
96 | */
97 | public function setItem(name: String, value: Object): void {
98 | if (value == null) {
99 | return;
100 | }
101 |
102 | if (value is String) {
103 | this._map[name] = value;
104 | } else {
105 | this._map[name] = value.toString();
106 | }
107 |
108 | }
109 |
110 | /**
111 | *
112 | * @param name
113 | * @return
114 | *
115 | */
116 | public function getItem(name: String): String {
117 |
118 | var value: String = this._map[name];
119 |
120 | return value;
121 |
122 | }
123 |
124 | /**
125 | *
126 | * @param name
127 | *
128 | */
129 | public function removeItem(name: String): void {
130 |
131 | delete this._map[name];
132 |
133 | }
134 |
135 | /**
136 | * 設定情報が空かどうかを調べます。
137 | * @return 設定情報が空の時true、そうでない時falseを返す。
138 | *
139 | */
140 | public function isEmpty(): Boolean {
141 | if (this._configIO.getNames().length == 0) {
142 | return true;
143 | } else {
144 | return false;
145 | }
146 | }
147 |
148 | /**
149 | * 設定ファイルの場所を示すネイティブパスの文字列表現を返します。
150 | * @return
151 | *
152 | */
153 | public function get confFileNativePath(): String {
154 | return this._configIO.confFileNativePath;
155 | }
156 |
157 | /**
158 | * 設定ファイルを示すファイルのインスタンスを返します。
159 | * @return
160 | *
161 | */
162 | public function get confFile(): File {
163 | return this._configIO.confFile;
164 | }
165 |
166 | }
167 | }
--------------------------------------------------------------------------------
/src/org/mineap/util/font/FontUtil.as:
--------------------------------------------------------------------------------
1 | package org.mineap.util.font {
2 | import flash.text.Font;
3 |
4 | import mx.core.FlexGlobals;
5 |
6 | /**
7 | * アプリケーションで使用するフォントの一覧を管理するクラスです。
8 | * @author shiraminekeisuke
9 | *
10 | */
11 | public class FontUtil {
12 | /**
13 | *
14 | *
15 | */
16 | public function FontUtil() {
17 | }
18 |
19 | /**
20 | * アプリケーションで使用可能なフォントの一覧を返します。
21 | * @return 使用可能なフォントの一覧
22 | */
23 | public static function fontList(): Vector. {
24 | var fonts: Vector. = new Vector.();
25 |
26 | var array: Array = Font.enumerateFonts(true);
27 | for each(var font: Font in array) {
28 | fonts.push(font);
29 | }
30 |
31 | return fonts;
32 |
33 | }
34 |
35 | /**
36 | * アプリケーションで使用するフォントを設定します。
37 | * @param fontName 設定するフォントの名前
38 | * @return 設定後、実際にアプリケーションに登録されたフォントの名前
39 | */
40 | public static function setFont(fontName: String): String {
41 | if (fontName != null) {
42 | FlexGlobals.topLevelApplication.setStyle("fontFamily", fontName);
43 | FlexGlobals.topLevelApplication.setPlayerFont(fontName);
44 | }
45 | return FlexGlobals.topLevelApplication.getStyle("fontFamily");
46 | }
47 |
48 | /**
49 | *
50 | * @param fontSize
51 | * @return
52 | *
53 | */
54 | public static function setSize(fontSize: int): String {
55 | FlexGlobals.topLevelApplication.setStyle("fontSize", fontSize);
56 | FlexGlobals.topLevelApplication.setPlayerFontSize(fontSize);
57 | return FlexGlobals.topLevelApplication.getStyle("fontSize");
58 | }
59 |
60 | /**
61 | * 現在のアプリケーションに設定されているフォントの名前を返します。
62 | * @return
63 | *
64 | */
65 | public static function get applicationFont(): String {
66 | return FlexGlobals.topLevelApplication.getStyle("fontFamily");
67 | }
68 |
69 | public static function get applicationFontSize(): int {
70 | return FlexGlobals.topLevelApplication.getStyle("fontSize");
71 | }
72 |
73 | /**
74 | * 指定された文字列をFont.fontNameプロパティに持つFontを探して返します。
75 | * 存在しない場合はnullを返します。
76 | * @param fontName
77 | * @return
78 | *
79 | */
80 | public static function getFontByName(fontName: String): Font {
81 |
82 | var vector: Vector. = FontUtil.fontList();
83 | for each(var font: Font in vector) {
84 | if (font.fontName == fontName) {
85 | return font;
86 | }
87 | }
88 |
89 | return null;
90 | }
91 |
92 | }
93 | }
--------------------------------------------------------------------------------
/src/player/NNDDicons_pause_20x20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nndd-reboot/NNDD/cd15e326435cf8428f75e8de173981673d1f57b0/src/player/NNDDicons_pause_20x20.png
--------------------------------------------------------------------------------
/src/player/NNDDicons_play_20x20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nndd-reboot/NNDD/cd15e326435cf8428f75e8de173981673d1f57b0/src/player/NNDDicons_play_20x20.png
--------------------------------------------------------------------------------
/src/player/NNDDicons_stop_20x20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nndd-reboot/NNDD/cd15e326435cf8428f75e8de173981673d1f57b0/src/player/NNDDicons_stop_20x20.png
--------------------------------------------------------------------------------
/utils/category_list_update/fetch_ranking_genre_tags.ts:
--------------------------------------------------------------------------------
1 | import * as axios from "axios";
2 | import * as cheerio from "cheerio";
3 | import * as moment from "moment";
4 |
5 | interface Genre {
6 | id: string;
7 | name: string;
8 | }
9 |
10 | type RankingTags = Array;
11 |
12 | (async () => {
13 | const genres = await fetchRankingGenreList();
14 | const tags: RankingTags = [];
15 |
16 | for (const genre of genres) {
17 | tags.push({
18 | id: genre.id,
19 | name: genre.name,
20 | tags: await fetchRankingTagList(genre.id),
21 | });
22 | }
23 |
24 | const category_list = {
25 | version: moment.default().format("YYYYMMDD"),
26 | category_list: tags,
27 | };
28 |
29 | console.log(JSON.stringify(category_list, null, " "));
30 | })();
31 |
32 | async function fetchRankingGenreList(): Promise {
33 | const client = axios.default;
34 | const result = (await client.get("https://www.nicovideo.jp/ranking")).data;
35 | const dom = cheerio.load(result);
36 |
37 | const genre: Genre[] = [];
38 | dom(".RankingGenreListContainer").find("li").find("a").each((_, element) => {
39 | if (!("attribs" in element)) {
40 | return;
41 | }
42 |
43 | if (!("href" in element.attribs)) {
44 | return;
45 | }
46 |
47 | const path = element.attribs["href"];
48 | const matches = path.match(/^\/ranking\/genre\/([^?\/]+)/);
49 | if (matches === null) {
50 | return;
51 | }
52 |
53 | genre.push({
54 | id: matches[1],
55 | name: dom(element).text().trim(),
56 | });
57 | });
58 |
59 | return genre;
60 | }
61 |
62 | async function fetchRankingTagList(genre: string) {
63 | const url = "https://www.nicovideo.jp/ranking/genre/" + genre;
64 | const client = axios.default;
65 | const result = (await client.get(url)).data;
66 | const dom = cheerio.load(result);
67 |
68 | const tags: string[] = [];
69 | dom(".RepresentedTagsContainer").find(".RankingFilterTag").each((_, element) => {
70 | const tag = dom(element).text().trim();
71 | if (tag !== "すべて") {
72 | tags.push(tag);
73 | }
74 | });
75 |
76 | return tags;
77 | }
78 |
--------------------------------------------------------------------------------
/utils/category_list_update/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "scripts",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "MIT",
11 | "dependencies": {
12 | "axios": "^0.24.0",
13 | "cheerio": "^1.0.0-rc.10",
14 | "moment": "^2.29.1",
15 | "typescript": "^4.5.4"
16 | },
17 | "devDependencies": {
18 | "@types/cheerio": "^0.22.30",
19 | "@types/moment": "^2.13.0",
20 | "ts-node": "^10.4.0"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------