ani-cli-npm 2.0.9 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.MD CHANGED
@@ -27,7 +27,7 @@ npx ani-cli-npm@latest
27
27
  ```
28
28
 
29
29
  ### Linux:
30
- #### - Install [nodejs](https://nodejs.org/en/download/ with your distrabutions package manager.
30
+ #### - Install [nodejs](https://nodejs.org/en/download/) with your distrabutions package manager.
31
31
  #### - Run the following command:
32
32
  ```
33
33
  npx ani-cli-npm@latest
package/bin/Anime.js CHANGED
@@ -7,6 +7,7 @@ const generate_link_1 = require("./generate_link");
7
7
  const cache_1 = require("./cache");
8
8
  const input_1 = require("./input");
9
9
  const load_config_1 = require("./load_config");
10
+ const W2GClient = require("w2g-client");
10
11
  const open = require("open");
11
12
  const PlayerController = require("media-player-controller");
12
13
  const dl = require("download-file-with-progressbar");
@@ -121,8 +122,9 @@ class Anime {
121
122
  console.log(("Opening MPV.."));
122
123
  this.player = await new PlayerController({
123
124
  app: 'mpv',
124
- args: ['--fullscreen'],
125
- media: await this.get_episode_link(episode, config.player)
125
+ args: ['--fullscreen', '--keep-open=yes'],
126
+ media: await this.get_episode_link(episode, config.player),
127
+ ipcPath: config.mpv_socket_path
126
128
  });
127
129
  // @ts-ignore
128
130
  await this.player.launch(err => {
@@ -135,7 +137,9 @@ class Anime {
135
137
  this.player = await new PlayerController({
136
138
  app: 'vlc',
137
139
  args: ['--fullscreen'],
138
- media: await this.get_episode_link(episode, config.player)
140
+ media: await this.get_episode_link(episode, config.player),
141
+ //httpPort: (config.vlc_socket !== 0)? config.vlc_socket : null, // HTTP port for local communication (vlc only)
142
+ //httpPass: (config.vlc_pass !== "")? config.vlc_socket : null,
139
143
  });
140
144
  // @ts-ignore
141
145
  await this.player.launch(err => {
@@ -147,6 +151,18 @@ class Anime {
147
151
  console.log(("Opening browser..."));
148
152
  await open(await this.get_episode_link(episode, config.player));
149
153
  break;
154
+ case "W2G":
155
+ try {
156
+ this.player = new W2GClient.W2GClient(config.w2g_api_key);
157
+ await this.player.create(await this.get_episode_link(episode, config.player));
158
+ console.log(chalk.green("Room link: " + await this.player.getLink()));
159
+ }
160
+ catch {
161
+ console.log(chalk.red("Failed to create w2g.tv room. \nthis can often be because your API token is invalid. You can change it in options."));
162
+ process.exit();
163
+ }
164
+ await open(await this.player.getLink());
165
+ break;
150
166
  case "LINK":
151
167
  this.player = 1;
152
168
  console.log(await this.get_episode_link(episode, config.player));
@@ -168,6 +184,10 @@ class Anime {
168
184
  else if (this.player == 1) {
169
185
  console.log(await this.get_episode_link(episode));
170
186
  }
187
+ else if (this.player.roomID != undefined) {
188
+ console.log(chalk.green("Room link: " + await this.player.getLink()));
189
+ this.player.update(await this.get_episode_link(episode));
190
+ }
171
191
  else if (this.player.opts.app == "mpv") {
172
192
  await this.player.load(await this.get_episode_link(episode));
173
193
  }
@@ -3,66 +3,97 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.config_ = void 0;
4
4
  const chalk = require("chalk");
5
5
  const input_1 = require("./input");
6
+ const configs = [
7
+ (async (temp) => {
8
+ temp.player = [
9
+ "VLC",
10
+ "BROWSER",
11
+ "MPV",
12
+ "W2G",
13
+ "LINK",
14
+ ][await (0, input_1.selection)([
15
+ "VLC - VLC media player",
16
+ "Browser - Play in default browser",
17
+ "MPV - MPV media player",
18
+ "w2g.tv - Watch together with friends in browser (Specify api token to create rooms linked to your account)",
19
+ "Link - Simply display the link in console"
20
+ ], [], ((item) => { return chalk.cyan(item); }), ((item) => { return chalk.cyan(item); }))];
21
+ // @ts-ignore
22
+ return temp, 0;
23
+ }),
24
+ (async (temp) => {
25
+ console.log(chalk.cyan("New Proxy;"));
26
+ temp.proxy = (await ((0, input_1.input)())).replaceAll(" ", "");
27
+ // @ts-ignore
28
+ return temp, 0;
29
+ }),
30
+ (async (temp) => {
31
+ console.log(chalk.cyan("New User Agent"));
32
+ temp.user_agent = await ((0, input_1.input)());
33
+ // @ts-ignore
34
+ return temp, 0;
35
+ }),
36
+ (async (temp) => {
37
+ console.log(chalk.cyan("New Downloads Folder"));
38
+ temp.download_folder = await ((0, input_1.input)());
39
+ // @ts-ignore
40
+ return temp, 0;
41
+ }),
42
+ (async (temp) => {
43
+ console.log(chalk.cyan("New socket file"));
44
+ temp.mpv_socket_path = await ((0, input_1.input)());
45
+ // @ts-ignore
46
+ return temp, 0;
47
+ }),
48
+ (async (temp) => {
49
+ console.log(chalk.cyan("New VLC socket"));
50
+ temp.vlc_socket = await ((0, input_1.input)());
51
+ // @ts-ignore
52
+ return temp, 0;
53
+ }),
54
+ (async (temp) => {
55
+ console.log(chalk.cyan("New VLC password"));
56
+ temp.vlc_pass = await ((0, input_1.input)());
57
+ // @ts-ignore
58
+ return temp, 0;
59
+ }),
60
+ (async (temp) => {
61
+ console.log(chalk.cyan("New w2g.tv api token"));
62
+ temp.w2g_api_key = await ((0, input_1.input)());
63
+ // @ts-ignore
64
+ return temp, 0;
65
+ }),
66
+ (async (temp) => {
67
+ // @ts-ignore
68
+ return temp, 1;
69
+ }),
70
+ (async (temp) => {
71
+ // @ts-ignore
72
+ return temp, 2;
73
+ })
74
+ ];
6
75
  async function config_(temp) {
7
76
  /*
8
77
  ## Lets user change a single attribute of config. Returns new config object, and an exit code
78
+
79
+ ### 0 to continue (generic return)
80
+ ### 1 To confirm (Save and exit)
81
+ ### 2 to cancel (exit without saving changes)
9
82
  */
10
83
  console.clear();
11
84
  console.log(chalk.blue("ANI-CLI-NPM \n"));
12
85
  console.log(chalk.yellow("Config:\n"));
13
- let choice = await (0, input_1.selection)([
86
+ return configs[await (0, input_1.selection)([
14
87
  "Player; " + temp.player,
15
88
  "Proxy; " + temp.proxy,
16
89
  "User agent; " + temp.user_agent,
17
90
  "Downloads folder; " + temp.download_folder,
91
+ "Mpv socket connection file; " + temp.mpv_socket_path,
92
+ "VLC socket; " + temp.vlc_socket,
93
+ "VLC pass; " + temp.vlc_pass,
94
+ "W2G api token: " + temp.w2g_api_key,
18
95
  "Save and exit",
19
96
  "Exit without saving"
20
- ], [], ((item) => { return chalk.cyan(item); }), ((item) => { return chalk.cyan(item); }));
21
- switch (choice) {
22
- case 0:
23
- let player = await (0, input_1.selection)([
24
- "VLC - VLC media player",
25
- "Browser - Play in default browser",
26
- "MPV - MPV media player",
27
- "Link - Simply display the link in console"
28
- ], [], ((item) => { return chalk.cyan(item); }), ((item) => { return chalk.cyan(item); }));
29
- switch (player) {
30
- case 0:
31
- temp.player = "VLC";
32
- break;
33
- case 1:
34
- temp.player = "BROWSER";
35
- break;
36
- case 2:
37
- temp.player = "MPV";
38
- break;
39
- case 3:
40
- temp.player = "LINK";
41
- break;
42
- }
43
- // @ts-ignore
44
- return temp, 0;
45
- case 1:
46
- console.log(chalk.cyan("New Proxy;"));
47
- temp.proxy = (await ((0, input_1.input)())).replaceAll(" ", "");
48
- // @ts-ignore
49
- return temp, 0;
50
- case 2:
51
- console.log(chalk.cyan("New User Agent"));
52
- temp.user_agent = await ((0, input_1.input)());
53
- // @ts-ignore
54
- return temp, 0;
55
- case 3:
56
- console.log(chalk.cyan("New Downloads Folder"));
57
- temp.download_folder = await ((0, input_1.input)());
58
- // @ts-ignore
59
- return temp, 0;
60
- case 4:
61
- // @ts-ignore
62
- return temp, 1;
63
- case 5:
64
- // @ts-ignore
65
- return temp, 2;
66
- }
97
+ ], [], ((item) => { return chalk.cyan(item); }), ((item) => { return chalk.cyan(item); }))](temp);
67
98
  }
68
99
  exports.config_ = config_;
@@ -32,6 +32,7 @@ async function generate_link(provider, id, player) {
32
32
  return post;
33
33
  case 2:
34
34
  provider_name = 'Animixplay';
35
+ console.log(`Fetching ${provider_name} links...`);
35
36
  let buffer = new Buffer(id);
36
37
  let enc_id = buffer.toString("base64");
37
38
  buffer = new Buffer(id + "LTXs3GrU8we9O" + enc_id);
package/bin/index.js CHANGED
@@ -51,7 +51,7 @@ async function main() {
51
51
  episode_number = await (0, input_1.number_input)(anime.episode_list.length, 1, (anime.most_recent != 0) ? ["c"] : [], (anime.most_recent != 0) ? [anime.most_recent + 1] : []);
52
52
  }
53
53
  await anime.play_head(episode_number - 1, config, cache_folder);
54
- if (anime.player != 1 && anime.player != 0) {
54
+ if (anime.player.hasOwnProperty("quit")) {
55
55
  await anime.player.quit();
56
56
  }
57
57
  await main();
@@ -66,7 +66,7 @@ async function main() {
66
66
  let continue_anime = new Anime_1.Anime();
67
67
  await continue_anime.init(config.most_recent.anime_id, cache_folder);
68
68
  await continue_anime.play_head(config.most_recent.episode_number, config, cache_folder);
69
- if (continue_anime.player != 0 && continue_anime.player != 1) {
69
+ if (continue_anime.player.hasOwnProperty("quit")) {
70
70
  await continue_anime.player.quit();
71
71
  }
72
72
  await main();
@@ -57,7 +57,11 @@ function load_config(cache_dir) {
57
57
  anime_id: ""
58
58
  },
59
59
  download_folder: ".",
60
- debug_mode: false
60
+ debug_mode: false,
61
+ mpv_socket_path: "",
62
+ vlc_socket: 0,
63
+ vlc_pass: "",
64
+ w2g_api_key: ""
61
65
  };
62
66
  if (fs.existsSync(cache_dir + "/config.conf")) {
63
67
  // @ts-ignore
@@ -83,6 +87,15 @@ function load_config(cache_dir) {
83
87
  // @ts-ignore
84
88
  if (tmp.download_folder !== undefined)
85
89
  config.download_folder = tmp.download_folder;
90
+ // @ts-ignore
91
+ if (tmp.mpv_socket_path !== undefined)
92
+ config.mpv_socket_path = tmp.mpv_socket_path;
93
+ // @ts-ignore
94
+ if (tmp.vlc_socket !== undefined)
95
+ config.vlc_socket = tmp.vlc_socket;
96
+ // @ts-ignore
97
+ if (tmp.vlc_pass !== undefined)
98
+ config.vlc_pass = tmp.vlc_pass;
86
99
  }
87
100
  write_config(cache_dir, config);
88
101
  return config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ani-cli-npm",
3
- "version": "2.0.9",
3
+ "version": "2.1.0",
4
4
  "description": "ani-cli tool rewritten as npm package",
5
5
  "main": "bin/index.js",
6
6
  "scripts": {
@@ -36,7 +36,8 @@
36
36
  "node-fetch": "^2.6.6",
37
37
  "open": "^8.4.0",
38
38
  "simple-input": "^1.0.1",
39
- "typescript": "^4.9.3"
39
+ "typescript": "^4.9.3",
40
+ "w2g-client": "^1.1.0"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@types/node": "^18.11.9"
package/tem.js ADDED
@@ -0,0 +1,13 @@
1
+ const W2GClient = require("w2g-client")
2
+
3
+ let client = new W2GClient.W2GClient("sovw9okdu5kb9vr39yy9k34u25sftalqz5ntluxshn48ooza1x5ih3yzaay6ie097z")
4
+
5
+ async function main(){
6
+ await client.create()
7
+ console.log(client.getLink())
8
+ await client.update("https://wwwx12.gogocdn.stream/videos/hls/nHDWH61tDXm9bXm7-tFVIw/1670878227/107271/f23efce39606d64216a0023544f49bb4/ep.29.1662456614.m3u8")
9
+
10
+ }
11
+
12
+ main()
13
+
package/temp DELETED
@@ -1,16 +0,0 @@
1
- et_video_quality_mp4() {
2
- case $quality in
3
- best)
4
- video_url=$(printf '%s' "$1" | tail -n 1 | cut -d">" -f2) ;;
5
- worst)
6
- video_url=$(printf '%s' "$1" | head -n 1 | cut -d">" -f2) ;;
7
- *)
8
- video_url=$(printf '%s' "$1" | grep -i "${quality}p" | head -n 1 | cut -d">" -f2)
9
- if [ -z "$video_url" ]; then
10
- err "Current video quality is not available (defaulting to best quality)"
11
- video_url=$(printf '%s' "$1" | tail -n 1 | cut -d">" -f2)
12
- fi
13
- ;;
14
- esac
15
- printf '%s' "$video_url"
16
- }