|
@@ -111,24 +111,28 @@ namespace Bmp.Core.Playback.Inputs
|
|
|
{
|
|
|
// TODO: InputSourceProvider::ExpandPath M3U(8) ISO ZIP RAR 7Z / InURL
|
|
|
// TODO: InputSourceProvider::ExpandPath EventBus for warn and err
|
|
|
- // [http://]foo.bar/foo.zip?path/to/inner/01.flac
|
|
|
+ // [http[s]://foo.bar/]foo.zip?#path/to/inner/01.flac
|
|
|
|
|
|
var (exists, size) = FileCheckSize(inputPath);
|
|
|
if (exists)
|
|
|
{
|
|
|
var ex = Path.GetExtension(inputPath).ToLower();
|
|
|
using var stream = ReadContentAsSeekableStream(inputPath);
|
|
|
+
|
|
|
// ------------ m3u/8 ------------
|
|
|
- if (size.HasValue && size < 1024 * 1025 * 1) // < 1MB
|
|
|
+ if (size.HasValue && size > 1024 * 1024)
|
|
|
+ {
|
|
|
+ // > 1MB may not playlist, skip
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
const string sign_ExtM3u = "#EXTM3U";
|
|
|
if (Encoding.ASCII.GetString(stream.ReadBytes(sign_ExtM3u.Length)) == sign_ExtM3u)
|
|
|
{
|
|
|
stream.Position = 0;
|
|
|
var lines = stream.ReadLines(ex == ".m3u8" ? Encoding.UTF8 : null);
|
|
|
- return lines.Where(p => p.StartsWith("#")).ToArray();
|
|
|
+ return lines.Where(p => p.StartsWith("#") == false).ToArray();
|
|
|
}
|
|
|
- //TODO: Debug here
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -178,13 +182,11 @@ namespace Bmp.Core.Playback.Inputs
|
|
|
else
|
|
|
{
|
|
|
using var client = new HttpClient();
|
|
|
- var request = new HttpRequestMessage(HttpMethod.Head, urlOrPath);
|
|
|
- var response = client.Send(request);
|
|
|
+ // use GET instead of HEAD for compatible
|
|
|
+ using var request = new HttpRequestMessage(HttpMethod.Get, urlOrPath);
|
|
|
+ using var response = client.Send(request, HttpCompletionOption.ResponseHeadersRead);
|
|
|
exists = response.IsSuccessStatusCode;
|
|
|
- if (exists && response.Content.Headers.ContentLength.HasValue)
|
|
|
- {
|
|
|
- size = response.Content.Headers.ContentLength.Value;
|
|
|
- }
|
|
|
+ if (exists && response.Content.Headers.ContentLength.HasValue) size = response.Content.Headers.ContentLength.Value;
|
|
|
}
|
|
|
|
|
|
return (exists, size);
|