User Tools

Site Tools


play_list_check

Play List Check

using System;
using System.IO;
using System.Text;
 
namespace PlayListCheck
{
	class Program
	{
		static void Main(string[] args)
		{
			if (args.Length != 1)
			{
				Console.Write(
					"Usage: PlayListCheck directory" + Environment.NewLine +
					"       PlayListCheck file.m3u" + Environment.NewLine +
					Environment.NewLine +
					"If a directory is specified, all .m3u files in that directory will be checked."+ Environment.NewLine
				);
				Environment.Exit(1);
			}
 
			FileInfo[] playListFiles = null;
 
			if (Directory.Exists(args[0]))
				playListFiles = new DirectoryInfo(args[0]).GetFiles("*.m3u");
			else if (File.Exists(args[0]))
				playListFiles = new FileInfo[] {new FileInfo(args[0])};
			else
			{
				Console.Error.WriteLine("'{0}' is not a valid directory or play list file.", args[0]);
				Environment.Exit(-1);
			}
 
			foreach (FileInfo playListFile in playListFiles)
			{
				Console.WriteLine(playListFile.Name);
 
				using (StreamReader sr = new StreamReader(playListFile.FullName, Encoding.Default))
				{
					string line;
					while ((line = sr.ReadLine()) != null)
					{
						if (!line.StartsWith("#EXT", StringComparison.InvariantCultureIgnoreCase))
						{
							string filename = Path.Combine(playListFile.DirectoryName, line);
							if (!File.Exists(filename))
								Console.WriteLine("  Missing: {0}", filename);
						}
					}
				}
			}
		}
	}
}
play_list_check.txt · Last modified: 2017/01/01 20:05 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki