ani-auto 1.4.1 → 1.4.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ani-auto",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "automatic anime episode downloader",
5
5
  "bin": {
6
6
  "ani-auto": "src/cli.js"
package/src/engine.js CHANGED
@@ -112,26 +112,60 @@ async function promptAnimeSelection(watchList) {
112
112
  const status = item.anilistStatus ? chalk.gray(` [${item.anilistStatus}]`) : '';
113
113
  console.log(` ${chalk.cyan(i + 1)}. ${item.title}${watched}${status}`);
114
114
  });
115
- console.log(` ${chalk.cyan('a')}. All`);
115
+ console.log(` ${chalk.cyan('s')}. Search and select`);
116
116
  console.log('');
117
117
 
118
118
  const { input } = await inquirer.prompt([{
119
119
  type: 'input',
120
120
  name: 'input',
121
- message: 'Enter numbers to download (e.g. 1,3 or "a" for all):',
122
- default: 'a',
123
- validate: (val) => {
124
- if (val.trim().toLowerCase() === 'a') return true;
125
- const nums = val.split(',').map(s => parseInt(s.trim()));
126
- if (nums.some(isNaN)) return 'Enter comma-separated numbers or "a"';
127
- if (nums.some(n => n < 1 || n > watchList.length)) return `Numbers must be between 1 and ${watchList.length}`;
128
- return true;
129
- }
121
+ message: 'Enter numbers to download, "s" to search, or Enter for all:',
122
+ default: '',
130
123
  }]);
131
124
 
132
- if (input.trim().toLowerCase() === 'a') return watchList;
133
- const indices = input.split(',').map(s => parseInt(s.trim()) - 1);
134
- return indices.map(i => watchList[i]);
125
+ const choice = input.trim().toLowerCase();
126
+
127
+ if (choice === 's') {
128
+ const { query } = await inquirer.prompt([{
129
+ type: 'input',
130
+ name: 'query',
131
+ message: 'Search anime:',
132
+ default: '',
133
+ }]);
134
+
135
+ const searchTerm = query.trim().toLowerCase();
136
+ const filtered = searchTerm
137
+ ? watchList.filter(item => item.title.toLowerCase().includes(searchTerm))
138
+ : watchList;
139
+
140
+ if (!filtered.length) {
141
+ console.log(chalk.yellow(' No matching anime found.\n'));
142
+ return [];
143
+ }
144
+
145
+ console.log(chalk.bold(`\n Found ${filtered.length} match(es):`));
146
+
147
+ const { picked } = await inquirer.prompt([{
148
+ type: 'checkbox',
149
+ name: 'picked',
150
+ message: 'Select anime to download:',
151
+ choices: filtered.map(item => {
152
+ const watched = item.watchedEpisodes ? ` (watched: ${item.watchedEpisodes})` : '';
153
+ const status = item.anilistStatus ? ` [${item.anilistStatus}]` : '';
154
+ return {
155
+ name: `${item.title}${watched}${status}`,
156
+ value: item,
157
+ checked: true,
158
+ };
159
+ }),
160
+ pageSize: 15,
161
+ }]);
162
+
163
+ return picked.length ? picked : [];
164
+ }
165
+
166
+ if (!choice || choice === 'a') return watchList;
167
+ const indices = choice.split(',').map(s => parseInt(s.trim()) - 1);
168
+ return indices.map(i => watchList[i]).filter(Boolean);
135
169
  }
136
170
 
137
171
  // ── Per-anime download ─────────────────────────────────────────────────────
@@ -1,9 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(npm install *)",
5
- "Bash(npm cache *)"
6
- ]
7
- },
8
- "$version": 3
9
- }