@@ -2,6 +2,9 @@ import { BaseCommand } from "./base.js";
22import { CommandContext } from "../types/index.js" ;
33import { MediaService } from "../services/media.js" ;
44import { ErrorUtils , GeneralUtils } from '../utils/shared.js' ;
5+ import fs from 'fs' ;
6+ import path from 'path' ;
7+ import config from "../config.js" ;
58
69export default class PlayCommand extends BaseCommand {
710 name = "play" ;
@@ -27,8 +30,17 @@ export default class PlayCommand extends BaseCommand {
2730 if ( GeneralUtils . isValidUrl ( input ) ) {
2831 await this . handleUrl ( context , input ) ;
2932 } else {
30- // Try to find local video first
31- const video = context . videos . find ( m => m . name === input ) ;
33+ // Refresh video list from disk before matching
34+ const videoFiles = fs . readdirSync ( config . videosDir ) ;
35+ const refreshedVideos = videoFiles . map ( file => ( {
36+ name : path . parse ( file ) . name ,
37+ path : path . join ( config . videosDir , file )
38+ } ) ) ;
39+ context . videos . length = 0 ;
40+ context . videos . push ( ...refreshedVideos ) ;
41+
42+ // Case-insensitive match
43+ const video = context . videos . find ( m => m . name . toLowerCase ( ) === input . toLowerCase ( ) ) ;
3244
3345 if ( video ) {
3446 await this . handleLocalVideo ( context , video ) ;
0 commit comments