diff --git a/src/Avalonia.Gif/Avalonia.Gif.csproj b/src/Avalonia.Gif/Avalonia.Gif.csproj
deleted file mode 100644
index b83b9fb..0000000
--- a/src/Avalonia.Gif/Avalonia.Gif.csproj
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
- net7.0
- latest
- true
- enable
-
-
-
-
-
-
-
diff --git a/src/Avalonia.Gif/BgWorkerCommand.cs b/src/Avalonia.Gif/BgWorkerCommand.cs
deleted file mode 100644
index d561685..0000000
--- a/src/Avalonia.Gif/BgWorkerCommand.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Avalonia.Gif
-{
- internal enum BgWorkerCommand
- {
- Null,
- Play,
- Pause,
- Dispose
- }
-}
\ No newline at end of file
diff --git a/src/Avalonia.Gif/BgWorkerState.cs b/src/Avalonia.Gif/BgWorkerState.cs
deleted file mode 100644
index ab3bc38..0000000
--- a/src/Avalonia.Gif/BgWorkerState.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace Avalonia.Gif
-{
- internal enum BgWorkerState
- {
- Null,
- Start,
- Running,
- Paused,
- Complete,
- Dispose
- }
-}
\ No newline at end of file
diff --git a/src/Avalonia.Gif/Decoding/BlockTypes.cs b/src/Avalonia.Gif/Decoding/BlockTypes.cs
deleted file mode 100644
index ca2cc7a..0000000
--- a/src/Avalonia.Gif/Decoding/BlockTypes.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Avalonia.Gif.Decoding
-{
- internal enum BlockTypes
- {
- Empty = 0,
- Extension = 0x21,
- ImageDescriptor = 0x2C,
- Trailer = 0x3B,
- }
-}
\ No newline at end of file
diff --git a/src/Avalonia.Gif/Decoding/ExtensionType.cs b/src/Avalonia.Gif/Decoding/ExtensionType.cs
deleted file mode 100644
index ad7878b..0000000
--- a/src/Avalonia.Gif/Decoding/ExtensionType.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace Avalonia.Gif.Decoding
-{
- internal enum ExtensionType
- {
- GraphicsControl = 0xF9,
- Application = 0xFF
- }
-}
\ No newline at end of file
diff --git a/src/Avalonia.Gif/Decoding/FrameDisposal.cs b/src/Avalonia.Gif/Decoding/FrameDisposal.cs
deleted file mode 100644
index 178a3c5..0000000
--- a/src/Avalonia.Gif/Decoding/FrameDisposal.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Avalonia.Gif.Decoding
-{
- public enum FrameDisposal
- {
- Unknown = 0,
- Leave = 1,
- Background = 2,
- Restore = 3
- }
-}
\ No newline at end of file
diff --git a/src/Avalonia.Gif/Decoding/GifColor.cs b/src/Avalonia.Gif/Decoding/GifColor.cs
deleted file mode 100644
index 7534cc1..0000000
--- a/src/Avalonia.Gif/Decoding/GifColor.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Runtime.InteropServices;
-
-namespace Avalonia.Gif
-{
- [StructLayout(LayoutKind.Explicit)]
- public readonly struct GifColor
- {
- [FieldOffset(3)]
- public readonly byte A;
-
- [FieldOffset(2)]
- public readonly byte R;
-
- [FieldOffset(1)]
- public readonly byte G;
-
- [FieldOffset(0)]
- public readonly byte B;
-
- ///
- /// A struct that represents a ARGB color and is aligned as
- /// a BGRA bytefield in memory.
- ///
- /// Red
- /// Green
- /// Blue
- /// Alpha
- public GifColor(byte r, byte g, byte b, byte a = byte.MaxValue)
- {
- A = a;
- R = r;
- G = g;
- B = b;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Avalonia.Gif/Decoding/GifDecoder.cs b/src/Avalonia.Gif/Decoding/GifDecoder.cs
deleted file mode 100644
index 4a31742..0000000
--- a/src/Avalonia.Gif/Decoding/GifDecoder.cs
+++ /dev/null
@@ -1,657 +0,0 @@
-// This source file's Lempel-Ziv-Welch algorithm is derived from Chromium's Android GifPlayer
-// as seen here (https://github.com/chromium/chromium/blob/master/third_party/gif_player/src/jp/tomorrowkey/android/gifplayer)
-// Licensed under the Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
-// Copyright (C) 2015 The Gifplayer Authors. All Rights Reserved.
-
-// The rest of the source file is licensed under MIT License.
-// Copyright (C) 2018 Jumar A. Macato, All Rights Reserved.
-
-using Avalonia.Media.Imaging;
-using System;
-using System.Buffers;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading;
-using static Avalonia.Gif.Extensions.StreamExtensions;
-
-namespace Avalonia.Gif.Decoding
-{
- public sealed class GifDecoder : IDisposable
- {
- private static readonly ReadOnlyMemory G87AMagic
- = "GIF87a"u8.ToArray().AsMemory();
-
- private static readonly ReadOnlyMemory G89AMagic
- = "GIF89a"u8.ToArray().AsMemory();
-
- private static readonly ReadOnlyMemory NetscapeMagic
- = "NETSCAPE2.0"u8.ToArray().AsMemory();
-
- private static readonly TimeSpan FrameDelayThreshold = TimeSpan.FromMilliseconds(10);
- private static readonly TimeSpan FrameDelayDefault = TimeSpan.FromMilliseconds(100);
- private static readonly GifColor TransparentColor = new(0, 0, 0, 0);
- private static readonly int MaxTempBuf = 768;
- private static readonly int MaxStackSize = 4096;
- private static readonly int MaxBits = 4097;
-
- private readonly Stream _fileStream;
- private readonly CancellationToken _currentCtsToken;
- private readonly bool _hasFrameBackups;
-
- private int _gctSize, _bgIndex, _prevFrame = -1, _backupFrame = -1;
- private bool _gctUsed;
-
- private GifRect _gifDimensions;
-
- // private ulong _globalColorTable;
- private readonly int _backBufferBytes;
- private GifColor[] _bitmapBackBuffer;
-
- private short[] _prefixBuf;
- private byte[] _suffixBuf;
- private byte[] _pixelStack;
- private byte[] _indexBuf;
- private byte[] _backupFrameIndexBuf;
- private volatile bool _hasNewFrame;
-
- public GifHeader Header { get; private set; }
-
- public readonly List Frames = new();
-
- public PixelSize Size => new PixelSize(Header.Dimensions.Width, Header.Dimensions.Height);
-
- public GifDecoder(Stream fileStream, CancellationToken currentCtsToken)
- {
- _fileStream = fileStream;
- _currentCtsToken = currentCtsToken;
-
- ProcessHeaderData();
- ProcessFrameData();
-
- Header.IterationCount = Header.Iterations switch
- {
- -1 => new GifRepeatBehavior { Count = 1 },
- 0 => new GifRepeatBehavior { LoopForever = true },
- > 0 => new GifRepeatBehavior { Count = Header.Iterations },
- _ => Header.IterationCount
- };
-
- var pixelCount = _gifDimensions.TotalPixels;
-
- _hasFrameBackups = Frames
- .Any(f => f.FrameDisposalMethod == FrameDisposal.Restore);
-
- _bitmapBackBuffer = new GifColor[pixelCount];
- _indexBuf = new byte[pixelCount];
-
- if (_hasFrameBackups)
- _backupFrameIndexBuf = new byte[pixelCount];
-
- _prefixBuf = new short[MaxStackSize];
- _suffixBuf = new byte[MaxStackSize];
- _pixelStack = new byte[MaxStackSize + 1];
-
- _backBufferBytes = pixelCount * Marshal.SizeOf(typeof(GifColor));
- }
-
- public void Dispose()
- {
- Frames.Clear();
-
- _bitmapBackBuffer = null;
- _prefixBuf = null;
- _suffixBuf = null;
- _pixelStack = null;
- _indexBuf = null;
- _backupFrameIndexBuf = null;
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private int PixCoord(int x, int y) => x + y * _gifDimensions.Width;
-
- static readonly (int Start, int Step)[] Pass =
- {
- (0, 8),
- (4, 8),
- (2, 4),
- (1, 2)
- };
-
- private void ClearImage()
- {
- Array.Fill(_bitmapBackBuffer, TransparentColor);
- //ClearArea(_gifDimensions);
-
- _prevFrame = -1;
- _backupFrame = -1;
- }
-
- public void RenderFrame(int fIndex, WriteableBitmap writeableBitmap, bool forceClear = false)
- {
- if (_currentCtsToken.IsCancellationRequested)
- return;
-
- if (fIndex < 0 | fIndex >= Frames.Count)
- return;
-
- if (_prevFrame == fIndex)
- return;
-
- if (fIndex == 0 || forceClear || fIndex < _prevFrame)
- ClearImage();
-
- DisposePreviousFrame();
-
- _prevFrame++;
-
- // render intermediate frame
- for (int idx = _prevFrame; idx < fIndex; ++idx)
- {
- var prevFrame = Frames[idx];
-
- if (prevFrame.FrameDisposalMethod == FrameDisposal.Restore)
- continue;
-
- if (prevFrame.FrameDisposalMethod == FrameDisposal.Background)
- {
- ClearArea(prevFrame.Dimensions);
- continue;
- }
-
- RenderFrameAt(idx, writeableBitmap);
- }
-
- RenderFrameAt(fIndex, writeableBitmap);
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void RenderFrameAt(int idx, WriteableBitmap writeableBitmap)
- {
- var tmpB = ArrayPool.Shared.Rent(MaxTempBuf);
-
- var curFrame = Frames[idx];
- DecompressFrameToIndexBuffer(curFrame, _indexBuf, tmpB);
-
- if (_hasFrameBackups & curFrame.ShouldBackup)
- {
- Buffer.BlockCopy(_indexBuf, 0, _backupFrameIndexBuf, 0, curFrame.Dimensions.TotalPixels);
- _backupFrame = idx;
- }
-
- DrawFrame(curFrame, _indexBuf);
-
- _prevFrame = idx;
- _hasNewFrame = true;
-
- using var lockedBitmap = writeableBitmap.Lock();
- WriteBackBufToFb(lockedBitmap.Address);
-
- ArrayPool.Shared.Return(tmpB);
- }
-
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DrawFrame(GifFrame curFrame, Memory frameIndexSpan)
- {
- var activeColorTable =
- curFrame.IsLocalColorTableUsed ? curFrame.LocalColorTable : Header.GlobarColorTable;
-
- var cX = curFrame.Dimensions.X;
- var cY = curFrame.Dimensions.Y;
- var cH = curFrame.Dimensions.Height;
- var cW = curFrame.Dimensions.Width;
- var tC = curFrame.TransparentColorIndex;
- var hT = curFrame.HasTransparency;
-
- if (curFrame.IsInterlaced)
- {
- for (var i = 0; i < 4; i++)
- {
- var curPass = Pass[i];
- var y = curPass.Start;
- while (y < cH)
- {
- DrawRow(y);
- y += curPass.Step;
- }
- }
- }
- else
- {
- for (var i = 0; i < cH; i++)
- DrawRow(i);
- }
-
- //for (var row = 0; row < cH; row++)
- void DrawRow(int row)
- {
- // Get the starting point of the current row on frame's index stream.
- var indexOffset = row * cW;
-
- // Get the target backbuffer offset from the frames coords.
- var targetOffset = PixCoord(cX, row + cY);
- var len = _bitmapBackBuffer.Length;
-
- for (var i = 0; i < cW; i++)
- {
- var indexColor = frameIndexSpan.Span[indexOffset + i];
-
- if (activeColorTable == null || targetOffset >= len ||
- indexColor > activeColorTable.Length) return;
-
- if (!(hT & indexColor == tC))
- _bitmapBackBuffer[targetOffset] = activeColorTable[indexColor];
-
- targetOffset++;
- }
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DisposePreviousFrame()
- {
- if (_prevFrame == -1)
- return;
-
- var prevFrame = Frames[_prevFrame];
-
- switch (prevFrame.FrameDisposalMethod)
- {
- case FrameDisposal.Background:
- ClearArea(prevFrame.Dimensions);
- break;
- case FrameDisposal.Restore:
- if (_hasFrameBackups && _backupFrame != -1)
- DrawFrame(Frames[_backupFrame], _backupFrameIndexBuf);
- else
- ClearArea(prevFrame.Dimensions);
- break;
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void ClearArea(GifRect area)
- {
- for (var y = 0; y < area.Height; y++)
- {
- var targetOffset = PixCoord(area.X, y + area.Y);
- for (var x = 0; x < area.Width; x++)
- _bitmapBackBuffer[targetOffset + x] = TransparentColor;
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecompressFrameToIndexBuffer(GifFrame curFrame, Span indexSpan, byte[] tempBuf)
- {
- _fileStream.Position = curFrame.LzwStreamPosition;
- var totalPixels = curFrame.Dimensions.TotalPixels;
-
- // Initialize GIF data stream decoder.
- var dataSize = curFrame.LzwMinCodeSize;
- var clear = 1 << dataSize;
- var endOfInformation = clear + 1;
- var available = clear + 2;
- var oldCode = -1;
- var codeSize = dataSize + 1;
- var codeMask = (1 << codeSize) - 1;
-
- for (var code = 0; code < clear; code++)
- {
- _prefixBuf[code] = 0;
- _suffixBuf[code] = (byte)code;
- }
-
- // Decode GIF pixel stream.
- int bits, first, top, pixelIndex;
- var datum = bits = first = top = pixelIndex = 0;
-
- while (pixelIndex < totalPixels)
- {
- var blockSize = _fileStream.ReadBlock(tempBuf);
-
- if (blockSize == 0)
- break;
-
- var blockPos = 0;
-
- while (blockPos < blockSize)
- {
- datum += tempBuf[blockPos] << bits;
- blockPos++;
-
- bits += 8;
-
- while (bits >= codeSize)
- {
- // Get the next code.
- var code = datum & codeMask;
- datum >>= codeSize;
- bits -= codeSize;
-
- // Interpret the code
- if (code == clear)
- {
- // Reset decoder.
- codeSize = dataSize + 1;
- codeMask = (1 << codeSize) - 1;
- available = clear + 2;
- oldCode = -1;
- continue;
- }
-
- // Check for explicit end-of-stream
- if (code == endOfInformation)
- return;
-
- if (oldCode == -1)
- {
- indexSpan[pixelIndex++] = _suffixBuf[code];
- oldCode = code;
- first = code;
- continue;
- }
-
- var inCode = code;
- if (code >= available)
- {
- _pixelStack[top++] = (byte)first;
- code = oldCode;
-
- if (top == MaxBits)
- ThrowException();
- }
-
- while (code >= clear)
- {
- if (code >= MaxBits || code == _prefixBuf[code])
- ThrowException();
-
- _pixelStack[top++] = _suffixBuf[code];
- code = _prefixBuf[code];
-
- if (top == MaxBits)
- ThrowException();
- }
-
- first = _suffixBuf[code];
- _pixelStack[top++] = (byte)first;
-
- // Add new code to the dictionary
- if (available < MaxStackSize)
- {
- _prefixBuf[available] = (short)oldCode;
- _suffixBuf[available] = (byte)first;
- available++;
-
- if ((available & codeMask) == 0 && available < MaxStackSize)
- {
- codeSize++;
- codeMask += available;
- }
- }
-
- oldCode = inCode;
-
- // Drain the pixel stack.
- do
- {
- indexSpan[pixelIndex++] = _pixelStack[--top];
- } while (top > 0);
- }
- }
- }
-
- while (pixelIndex < totalPixels)
- indexSpan[pixelIndex++] = 0; // clear missing pixels
-
- void ThrowException() => throw new LzwDecompressionException();
- }
-
- ///
- /// Directly copies the struct array to a bitmap IntPtr.
- ///
- private void WriteBackBufToFb(IntPtr targetPointer)
- {
- if (_currentCtsToken.IsCancellationRequested)
- return;
-
- if (!(_hasNewFrame & _bitmapBackBuffer != null)) return;
-
- unsafe
- {
- fixed (void* src = &_bitmapBackBuffer[0])
- Buffer.MemoryCopy(src, targetPointer.ToPointer(), (uint)_backBufferBytes,
- (uint)_backBufferBytes);
- _hasNewFrame = false;
- }
- }
-
- ///
- /// Processes GIF Header.
- ///
- private void ProcessHeaderData()
- {
- var str = _fileStream;
- var tmpB = ArrayPool.Shared.Rent(MaxTempBuf);
- var tempBuf = tmpB.AsSpan();
-
- var _ = str.Read(tmpB, 0, 6);
-
- if (!tempBuf[..3].SequenceEqual(G87AMagic[..3].Span))
- throw new InvalidGifStreamException("Not a GIF stream.");
-
- if (!(tempBuf[..6].SequenceEqual(G87AMagic.Span) |
- tempBuf[..6].SequenceEqual(G89AMagic.Span)))
- throw new InvalidGifStreamException("Unsupported GIF Version: " +
- Encoding.ASCII.GetString(tempBuf[..6].ToArray()));
-
- ProcessScreenDescriptor(tmpB);
-
- Header = new GifHeader
- {
- Dimensions = _gifDimensions,
- HasGlobalColorTable = _gctUsed,
- // GlobalColorTableCacheID = _globalColorTable,
- GlobarColorTable = ProcessColorTable(ref str, tmpB, _gctSize),
- GlobalColorTableSize = _gctSize,
- BackgroundColorIndex = _bgIndex,
- HeaderSize = _fileStream.Position
- };
-
- ArrayPool.Shared.Return(tmpB);
- }
-
- ///
- /// Parses colors from file stream to target color table.
- ///
- private static GifColor[] ProcessColorTable(ref Stream stream, byte[] rawBufSpan, int nColors)
- {
- var nBytes = 3 * nColors;
- var target = new GifColor[nColors];
-
- var n = stream.Read(rawBufSpan, 0, nBytes);
-
- if (n < nBytes)
- throw new InvalidOperationException("Wrong color table bytes.");
-
- int i = 0, j = 0;
-
- while (i < nColors)
- {
- var r = rawBufSpan[j++];
- var g = rawBufSpan[j++];
- var b = rawBufSpan[j++];
- target[i++] = new GifColor(r, g, b);
- }
-
- return target;
- }
-
- ///
- /// Parses screen and other GIF descriptors.
- ///
- private void ProcessScreenDescriptor(byte[] tempBuf)
- {
- var width = _fileStream.ReadUShortS(tempBuf);
- var height = _fileStream.ReadUShortS(tempBuf);
-
- var packed = _fileStream.ReadByteS(tempBuf);
-
- _gctUsed = (packed & 0x80) != 0;
- _gctSize = 2 << (packed & 7);
- _bgIndex = _fileStream.ReadByteS(tempBuf);
-
- _gifDimensions = new GifRect(0, 0, width, height);
- _fileStream.Skip(1);
- }
-
- ///
- /// Parses all frame data.
- ///
- private void ProcessFrameData()
- {
- _fileStream.Position = Header.HeaderSize;
-
- var tempBuf = ArrayPool.Shared.Rent(MaxTempBuf);
-
- var terminate = false;
- var curFrame = 0;
-
- Frames.Add(new GifFrame());
-
- do
- {
- var blockType = (BlockTypes)_fileStream.ReadByteS(tempBuf);
-
- switch (blockType)
- {
- case BlockTypes.Empty:
- break;
-
- case BlockTypes.Extension:
- ProcessExtensions(ref curFrame, tempBuf);
- break;
-
- case BlockTypes.ImageDescriptor:
- ProcessImageDescriptor(ref curFrame, tempBuf);
- _fileStream.SkipBlocks(tempBuf);
- break;
-
- case BlockTypes.Trailer:
- Frames.RemoveAt(Frames.Count - 1);
- terminate = true;
- break;
-
- default:
- _fileStream.SkipBlocks(tempBuf);
- break;
- }
-
- // Break the loop when the stream is not valid anymore.
- if (_fileStream.Position >= _fileStream.Length & terminate == false)
- throw new InvalidProgramException("Reach the end of the filestream without trailer block.");
- } while (!terminate);
-
- ArrayPool.Shared.Return(tempBuf);
- }
-
- ///
- /// Parses GIF Image Descriptor Block.
- ///
- private void ProcessImageDescriptor(ref int curFrame, byte[] tempBuf)
- {
- var str = _fileStream;
- var currentFrame = Frames[curFrame];
-
- // Parse frame dimensions.
- var frameX = str.ReadUShortS(tempBuf);
- var frameY = str.ReadUShortS(tempBuf);
- var frameW = str.ReadUShortS(tempBuf);
- var frameH = str.ReadUShortS(tempBuf);
-
- frameW = (ushort)Math.Min(frameW, _gifDimensions.Width - frameX);
- frameH = (ushort)Math.Min(frameH, _gifDimensions.Height - frameY);
-
- currentFrame.Dimensions = new GifRect(frameX, frameY, frameW, frameH);
-
- // Unpack interlace and lct info.
- var packed = str.ReadByteS(tempBuf);
- currentFrame.IsInterlaced = (packed & 0x40) != 0;
- currentFrame.IsLocalColorTableUsed = (packed & 0x80) != 0;
- currentFrame.LocalColorTableSize = (int)Math.Pow(2, (packed & 0x07) + 1);
-
- if (currentFrame.IsLocalColorTableUsed)
- currentFrame.LocalColorTable =
- ProcessColorTable(ref str, tempBuf, currentFrame.LocalColorTableSize);
-
- currentFrame.LzwMinCodeSize = str.ReadByteS(tempBuf);
- currentFrame.LzwStreamPosition = str.Position;
-
- curFrame += 1;
- Frames.Add(new GifFrame());
- }
-
- ///
- /// Parses GIF Extension Blocks.
- ///
- private void ProcessExtensions(ref int curFrame, byte[] tempBuf)
- {
- var extType = (ExtensionType)_fileStream.ReadByteS(tempBuf);
-
- switch (extType)
- {
- case ExtensionType.GraphicsControl:
-
- _fileStream.ReadBlock(tempBuf);
- var currentFrame = Frames[curFrame];
- var packed = tempBuf[0];
-
- currentFrame.FrameDisposalMethod = (FrameDisposal)((packed & 0x1c) >> 2);
-
- if (currentFrame.FrameDisposalMethod != FrameDisposal.Restore
- && currentFrame.FrameDisposalMethod != FrameDisposal.Background)
- currentFrame.ShouldBackup = true;
-
- currentFrame.HasTransparency = (packed & 1) != 0;
-
- currentFrame.FrameDelay =
- TimeSpan.FromMilliseconds(SpanToShort(tempBuf.AsSpan(1)) * 10);
-
- if (currentFrame.FrameDelay <= FrameDelayThreshold)
- currentFrame.FrameDelay = FrameDelayDefault;
-
- currentFrame.TransparentColorIndex = tempBuf[3];
- break;
-
- case ExtensionType.Application:
- var blockLen = _fileStream.ReadBlock(tempBuf);
- var _ = tempBuf.AsSpan(0, blockLen);
- var blockHeader = tempBuf.AsSpan(0, NetscapeMagic.Length);
-
- if (blockHeader.SequenceEqual(NetscapeMagic.Span))
- {
- var count = 1;
-
- while (count > 0)
- count = _fileStream.ReadBlock(tempBuf);
-
- var iterationCount = SpanToShort(tempBuf.AsSpan(1));
-
- Header.Iterations = iterationCount;
- }
- else
- _fileStream.SkipBlocks(tempBuf);
-
- break;
-
- default:
- _fileStream.SkipBlocks(tempBuf);
- break;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Avalonia.Gif/Decoding/GifFrame.cs b/src/Avalonia.Gif/Decoding/GifFrame.cs
deleted file mode 100644
index e15a201..0000000
--- a/src/Avalonia.Gif/Decoding/GifFrame.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-
-namespace Avalonia.Gif.Decoding
-{
- public class GifFrame
- {
- public bool HasTransparency, IsInterlaced, IsLocalColorTableUsed;
- public byte TransparentColorIndex;
- public int LzwMinCodeSize, LocalColorTableSize;
- public long LzwStreamPosition;
- public TimeSpan FrameDelay;
- public FrameDisposal FrameDisposalMethod;
- public bool ShouldBackup;
- public GifRect Dimensions;
- public GifColor[] LocalColorTable;
- }
-}
\ No newline at end of file
diff --git a/src/Avalonia.Gif/Decoding/GifHeader.cs b/src/Avalonia.Gif/Decoding/GifHeader.cs
deleted file mode 100644
index d02dbc9..0000000
--- a/src/Avalonia.Gif/Decoding/GifHeader.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-// Licensed under the MIT License.
-// Copyright (C) 2018 Jumar A. Macato, All Rights Reserved.
-
-namespace Avalonia.Gif.Decoding
-{
- public class GifHeader
- {
- public bool HasGlobalColorTable;
- public int GlobalColorTableSize;
- public ulong GlobalColorTableCacheId;
- public int BackgroundColorIndex;
- public long HeaderSize;
- internal int Iterations = -1;
- public GifRepeatBehavior IterationCount;
- public GifRect Dimensions;
- private GifColor[] _globarColorTable;
- public GifColor[] GlobarColorTable;
- }
-}
\ No newline at end of file
diff --git a/src/Avalonia.Gif/Decoding/GifRect.cs b/src/Avalonia.Gif/Decoding/GifRect.cs
deleted file mode 100644
index 0ed9308..0000000
--- a/src/Avalonia.Gif/Decoding/GifRect.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-namespace Avalonia.Gif.Decoding
-{
- public readonly struct GifRect
- {
- public int X { get; }
- public int Y { get; }
- public int Width { get; }
- public int Height { get; }
- public int TotalPixels { get; }
-
- public GifRect(int x, int y, int width, int height)
- {
- X = x;
- Y = y;
- Width = width;
- Height = height;
- TotalPixels = width * height;
- }
-
- public static bool operator ==(GifRect a, GifRect b)
- {
- return a.X == b.X &&
- a.Y == b.Y &&
- a.Width == b.Width &&
- a.Height == b.Height;
- }
- public static bool operator !=(GifRect a, GifRect b)
- {
- return !(a == b);
- }
-
- public override bool Equals(object obj)
- {
- if (obj == null || GetType() != obj.GetType())
- return false;
-
- return this == (GifRect)obj;
- }
-
- public override int GetHashCode()
- {
- return X.GetHashCode() ^ Y.GetHashCode() | Width.GetHashCode() ^ Height.GetHashCode();
- }
- }
-}
\ No newline at end of file
diff --git a/src/Avalonia.Gif/Decoding/GifRepeatBehavior.cs b/src/Avalonia.Gif/Decoding/GifRepeatBehavior.cs
deleted file mode 100644
index 4b27a7b..0000000
--- a/src/Avalonia.Gif/Decoding/GifRepeatBehavior.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace Avalonia.Gif.Decoding
-{
- public class GifRepeatBehavior
- {
- public bool LoopForever { get; set; }
- public int? Count { get; set; }
- }
-}
diff --git a/src/Avalonia.Gif/Decoding/InvalidGifStreamException.cs b/src/Avalonia.Gif/Decoding/InvalidGifStreamException.cs
deleted file mode 100644
index 73c3124..0000000
--- a/src/Avalonia.Gif/Decoding/InvalidGifStreamException.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Licensed under the MIT License.
-// Copyright (C) 2018 Jumar A. Macato, All Rights Reserved.
-
-using System;
-using System.Runtime.Serialization;
-
-namespace Avalonia.Gif.Decoding
-{
- [Serializable]
- public class InvalidGifStreamException : Exception
- {
- public InvalidGifStreamException()
- {
- }
-
- public InvalidGifStreamException(string message) : base(message)
- {
- }
-
- public InvalidGifStreamException(string message, Exception innerException) : base(message, innerException)
- {
- }
-
- protected InvalidGifStreamException(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/src/Avalonia.Gif/Decoding/LzwDecompressionException.cs b/src/Avalonia.Gif/Decoding/LzwDecompressionException.cs
deleted file mode 100644
index 2e74aaf..0000000
--- a/src/Avalonia.Gif/Decoding/LzwDecompressionException.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Licensed under the MIT License.
-// Copyright (C) 2018 Jumar A. Macato, All Rights Reserved.
-
-using System;
-using System.Runtime.Serialization;
-
-namespace Avalonia.Gif.Decoding
-{
- [Serializable]
- public class LzwDecompressionException : Exception
- {
- public LzwDecompressionException()
- {
- }
-
- public LzwDecompressionException(string message) : base(message)
- {
- }
-
- public LzwDecompressionException(string message, Exception innerException) : base(message, innerException)
- {
- }
-
- protected LzwDecompressionException(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/src/Avalonia.Gif/Extensions/StreamExtensions.cs b/src/Avalonia.Gif/Extensions/StreamExtensions.cs
deleted file mode 100644
index d05bc63..0000000
--- a/src/Avalonia.Gif/Extensions/StreamExtensions.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.IO;
-using System.Runtime.CompilerServices;
-
-namespace Avalonia.Gif.Extensions
-{
- [DebuggerStepThrough]
- internal static class StreamExtensions
- {
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ushort SpanToShort(Span b) => (ushort)(b[0] | (b[1] << 8));
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static void Skip(this Stream stream, long count)
- {
- stream.Position += count;
- }
-
- ///
- /// Read a Gif block from stream while advancing the position.
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static int ReadBlock(this Stream stream, byte[] tempBuf)
- {
- stream.Read(tempBuf, 0, 1);
-
- var blockLength = (int)tempBuf[0];
-
- if (blockLength > 0)
- stream.Read(tempBuf, 0, blockLength);
-
- // Guard against infinite loop.
- if (stream.Position >= stream.Length)
- throw new InvalidGifStreamException("Reach the end of the filestream without trailer block.");
-
- return blockLength;
- }
-
- ///
- /// Skips GIF blocks until it encounters an empty block.
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static void SkipBlocks(this Stream stream, byte[] tempBuf)
- {
- int blockLength;
- do
- {
- stream.Read(tempBuf, 0, 1);
-
- blockLength = tempBuf[0];
- stream.Position += blockLength;
-
- // Guard against infinite loop.
- if (stream.Position >= stream.Length)
- throw new InvalidGifStreamException("Reach the end of the filestream without trailer block.");
-
- } while (blockLength > 0);
- }
-
- ///
- /// Read a from stream by providing a temporary buffer.
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ushort ReadUShortS(this Stream stream, byte[] tempBuf)
- {
- stream.Read(tempBuf, 0, 2);
- return SpanToShort(tempBuf);
- }
-
- ///
- /// Read a from stream by providing a temporary buffer.
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static byte ReadByteS(this Stream stream, byte[] tempBuf)
- {
- stream.Read(tempBuf, 0, 1);
- var finalVal = tempBuf[0];
- return finalVal;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Avalonia.Gif/GifImage.cs b/src/Avalonia.Gif/GifImage.cs
deleted file mode 100644
index 26c96a9..0000000
--- a/src/Avalonia.Gif/GifImage.cs
+++ /dev/null
@@ -1,276 +0,0 @@
-using Avalonia.Animation;
-using Avalonia.Controls;
-using Avalonia.Logging;
-using Avalonia.Media;
-using Avalonia.Rendering.Composition;
-using Avalonia.VisualTree;
-using System;
-using System.IO;
-using System.Numerics;
-
-namespace Avalonia.Gif
-{
- public class GifImage : Control
- {
- public static readonly StyledProperty SourceUriRawProperty =
- AvaloniaProperty.Register("SourceUriRaw");
-
- public static readonly StyledProperty SourceUriProperty =
- AvaloniaProperty.Register("SourceUri");
-
- public static readonly StyledProperty SourceStreamProperty =
- AvaloniaProperty.Register("SourceStream");
-
- public static readonly StyledProperty IterationCountProperty =
- AvaloniaProperty.Register("IterationCount", IterationCount.Infinite);
-
- private GifInstance? _gifInstance;
-
- public static readonly StyledProperty StretchDirectionProperty =
- AvaloniaProperty.Register("StretchDirection");
-
- public static readonly StyledProperty StretchProperty =
- AvaloniaProperty.Register("Stretch");
-
- private CompositionCustomVisual? _customVisual;
-
- private object? _initialSource = null;
-
- protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
- {
- switch (change.Property.Name)
- {
- case nameof(SourceUriRaw):
- case nameof(SourceUri):
- case nameof(SourceStream):
- SourceChanged(change);
- break;
- case nameof(Stretch):
- case nameof(StretchDirection):
- InvalidateArrange();
- InvalidateMeasure();
- Update();
- break;
- case nameof(IterationCount):
- IterationCountChanged(change);
- break;
- case nameof(Bounds):
- Update();
- break;
- }
-
- base.OnPropertyChanged(change);
- }
-
- public string SourceUriRaw
- {
- get => GetValue(SourceUriRawProperty);
- set => SetValue(SourceUriRawProperty, value);
- }
-
- public Uri SourceUri
- {
- get => GetValue(SourceUriProperty);
- set => SetValue(SourceUriProperty, value);
- }
-
- public Stream SourceStream
- {
- get => GetValue(SourceStreamProperty);
- set => SetValue(SourceStreamProperty, value);
- }
-
- public IterationCount IterationCount
- {
- get => GetValue(IterationCountProperty);
- set => SetValue(IterationCountProperty, value);
- }
-
- public StretchDirection StretchDirection
- {
- get => GetValue(StretchDirectionProperty);
- set => SetValue(StretchDirectionProperty, value);
- }
-
- public Stretch Stretch
- {
- get => GetValue(StretchProperty);
- set => SetValue(StretchProperty, value);
- }
-
- private static void IterationCountChanged(AvaloniaPropertyChangedEventArgs e)
- {
- var image = e.Sender as GifImage;
- if (image is null || e.NewValue is not IterationCount iterationCount)
- return;
-
- image.IterationCount = iterationCount;
- }
-
- protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
- {
- var compositor = ElementComposition.GetElementVisual(this)?.Compositor;
- if (compositor == null || _customVisual?.Compositor == compositor)
- return;
- _customVisual = compositor.CreateCustomVisual(new CustomVisualHandler());
- ElementComposition.SetElementChildVisual(this, _customVisual);
- _customVisual.SendHandlerMessage(CustomVisualHandler.StartMessage);
-
- if (_initialSource is not null)
- {
- UpdateGifInstance(_initialSource);
- _initialSource = null;
- }
-
- Update();
- base.OnAttachedToVisualTree(e);
- }
-
-
- private void Update()
- {
- if (_customVisual is null || _gifInstance is null)
- return;
-
- var dpi = this.GetVisualRoot()?.RenderScaling ?? 1.0;
- var sourceSize = _gifInstance.GifPixelSize.ToSize(dpi);
- var viewPort = new Rect(Bounds.Size);
-
- var scale = Stretch.CalculateScaling(Bounds.Size, sourceSize, StretchDirection);
- var scaledSize = sourceSize * scale;
- var destRect = viewPort
- .CenterRect(new Rect(scaledSize))
- .Intersect(viewPort);
-
- if (Stretch == Stretch.None)
- {
- _customVisual.Size = new Vector2((float)sourceSize.Width, (float)sourceSize.Height);
- }
- else
- {
- _customVisual.Size = new Vector2((float)destRect.Size.Width, (float)destRect.Size.Height);
- }
-
- _customVisual.Offset = new Vector3((float)destRect.Position.X, (float)destRect.Position.Y, 0);
- }
-
- private class CustomVisualHandler : CompositionCustomVisualHandler
- {
- private TimeSpan _animationElapsed;
- private TimeSpan? _lastServerTime;
- private GifInstance? _currentInstance;
- private bool _running;
-
- public static readonly object StopMessage = new(), StartMessage = new();
-
- public override void OnMessage(object message)
- {
- if (message == StartMessage)
- {
- _running = true;
- _lastServerTime = null;
- RegisterForNextAnimationFrameUpdate();
- }
- else if (message == StopMessage)
- {
- _running = false;
- }
- else if (message is GifInstance instance)
- {
- _currentInstance?.Dispose();
- _currentInstance = instance;
- }
- }
-
- public override void OnAnimationFrameUpdate()
- {
- if (!_running) return;
- Invalidate();
- RegisterForNextAnimationFrameUpdate();
- }
-
- public override void OnRender(ImmediateDrawingContext drawingContext)
- {
- if (_running)
- {
- if (_lastServerTime.HasValue) _animationElapsed += (CompositionNow - _lastServerTime.Value);
- _lastServerTime = CompositionNow;
- }
-
- try
- {
- if (_currentInstance is null || _currentInstance.IsDisposed) return;
-
- var bitmap = _currentInstance.ProcessFrameTime(_animationElapsed);
- if (bitmap is not null)
- {
- drawingContext.DrawBitmap(bitmap, new Rect(_currentInstance.GifPixelSize.ToSize(1)),
- GetRenderBounds());
- }
- }
- catch (Exception e)
- {
- Logger.Sink?.Log(LogEventLevel.Error, "GifImage Renderer ", this, e.ToString());
-
- }
- }
- }
-
- ///
- /// Measures the control.
- ///
- /// The available size.
- /// The desired size of the control.
- protected override Size MeasureOverride(Size availableSize)
- {
- var result = new Size();
- var scaling = this.GetVisualRoot()?.RenderScaling ?? 1.0;
- if (_gifInstance != null)
- {
- result = Stretch.CalculateSize(availableSize, _gifInstance.GifPixelSize.ToSize(scaling),
- StretchDirection);
- }
-
- return result;
- }
-
- ///
- protected override Size ArrangeOverride(Size finalSize)
- {
- if (_gifInstance is null) return new Size();
- var scaling = this.GetVisualRoot()?.RenderScaling ?? 1.0;
- var sourceSize = _gifInstance.GifPixelSize.ToSize(scaling);
- var result = Stretch.CalculateSize(finalSize, sourceSize);
- return result;
- }
-
-
- private void SourceChanged(AvaloniaPropertyChangedEventArgs e)
- {
- if (e.NewValue is null || (e.NewValue is string value && !Uri.IsWellFormedUriString(value, UriKind.Absolute)))
- {
- return;
- }
-
- if (_customVisual is null)
- {
- _initialSource = e.NewValue;
- return;
- }
-
- UpdateGifInstance(e.NewValue);
-
- InvalidateArrange();
- InvalidateMeasure();
- Update();
- }
-
- private void UpdateGifInstance(object source)
- {
- _gifInstance?.Dispose();
- _gifInstance = new GifInstance(source);
- _gifInstance.IterationCount = IterationCount;
- _customVisual?.SendHandlerMessage(_gifInstance);
- }
- }
-}
diff --git a/src/Avalonia.Gif/GifInstance.cs b/src/Avalonia.Gif/GifInstance.cs
deleted file mode 100644
index c582453..0000000
--- a/src/Avalonia.Gif/GifInstance.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-using Avalonia.Animation;
-using Avalonia.Gif.Decoding;
-using Avalonia.Media.Imaging;
-using Avalonia.Platform;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading;
-
-namespace Avalonia.Gif
-{
- public class GifInstance : IDisposable
- {
- public IterationCount IterationCount { get; set; }
- public bool AutoStart { get; private set; } = true;
- private readonly GifDecoder _gifDecoder;
- private readonly WriteableBitmap? _targetBitmap;
- private TimeSpan _totalTime;
- private readonly List _frameTimes;
- private uint _iterationCount;
- private int _currentFrameIndex;
- private readonly List _colorTableIdList;
-
- public CancellationTokenSource CurrentCts { get; }
-
- internal GifInstance(object newValue) : this(newValue switch
- {
- Stream s => s,
- Uri u => GetStreamFromUri(u),
- string str => GetStreamFromString(str),
- _ => throw new InvalidDataException("Unsupported source object")
- })
- { }
-
- public GifInstance(string uri) : this(GetStreamFromString(uri))
- { }
-
- public GifInstance(Uri uri) : this(GetStreamFromUri(uri))
- { }
-
- public GifInstance(Stream currentStream)
- {
- if (!currentStream.CanSeek)
- throw new InvalidDataException("The provided stream is not seekable.");
-
- if (!currentStream.CanRead)
- throw new InvalidOperationException("Can't read the stream provided.");
-
- currentStream.Seek(0, SeekOrigin.Begin);
-
- CurrentCts = new CancellationTokenSource();
-
- _gifDecoder = new GifDecoder(currentStream, CurrentCts.Token);
- var pixSize = new PixelSize(_gifDecoder.Header.Dimensions.Width, _gifDecoder.Header.Dimensions.Height);
-
- _targetBitmap = new WriteableBitmap(pixSize, new Vector(96, 96), PixelFormat.Bgra8888, AlphaFormat.Opaque);
- GifPixelSize = pixSize;
-
- _totalTime = TimeSpan.Zero;
-
- _frameTimes = _gifDecoder.Frames.Select(frame =>
- {
- _totalTime = _totalTime.Add(frame.FrameDelay);
- return _totalTime;
- }).ToList();
-
- _gifDecoder.RenderFrame(0, _targetBitmap);
- }
-
- private static Stream GetStreamFromString(string str)
- {
- if (!Uri.TryCreate(str, UriKind.RelativeOrAbsolute, out var res))
- {
- throw new InvalidCastException("The string provided can't be converted to URI.");
- }
-
- return GetStreamFromUri(res);
- }
-
- private static Stream GetStreamFromUri(Uri uri)
- {
- var uriString = uri.OriginalString.Trim();
-
- if (!uriString.StartsWith("resm") && !uriString.StartsWith("avares"))
- throw new InvalidDataException(
- "The URI provided is not currently supported.");
-
- return AssetLoader.Open(uri);
- }
-
- public int GifFrameCount => _frameTimes.Count;
-
- public PixelSize GifPixelSize { get; }
-
- public void Dispose()
- {
- IsDisposed = true;
- CurrentCts.Cancel();
- _targetBitmap?.Dispose();
- }
-
- public bool IsDisposed { get; private set; }
-
-
- public WriteableBitmap? ProcessFrameTime(TimeSpan stopwatchElapsed)
- {
- if (!IterationCount.IsInfinite && _iterationCount > IterationCount.Value)
- {
- return null;
- }
-
- if (CurrentCts.IsCancellationRequested || _targetBitmap is null)
- {
- return null;
- }
-
- var elapsedTicks = stopwatchElapsed.Ticks;
- var timeModulus = TimeSpan.FromTicks(elapsedTicks % _totalTime.Ticks);
- var targetFrame = _frameTimes.FirstOrDefault(x => timeModulus < x);
- var currentFrame = _frameTimes.IndexOf(targetFrame);
- if (currentFrame == -1) currentFrame = 0;
-
- if (_currentFrameIndex == currentFrame)
- return _targetBitmap;
-
- _iterationCount = (uint)(elapsedTicks / _totalTime.Ticks);
-
- return ProcessFrameIndex(currentFrame);
- }
-
- internal WriteableBitmap ProcessFrameIndex(int frameIndex)
- {
- _gifDecoder.RenderFrame(frameIndex, _targetBitmap);
- _currentFrameIndex = frameIndex;
-
- return _targetBitmap;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Avalonia.Gif/InvalidGifStreamException.cs b/src/Avalonia.Gif/InvalidGifStreamException.cs
deleted file mode 100644
index dc10557..0000000
--- a/src/Avalonia.Gif/InvalidGifStreamException.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Runtime.Serialization;
-
-namespace Avalonia.Gif
-{
- [Serializable]
- internal class InvalidGifStreamException : Exception
- {
- public InvalidGifStreamException()
- {
- }
-
- public InvalidGifStreamException(string message) : base(message)
- {
- }
-
- public InvalidGifStreamException(string message, Exception innerException) : base(message, innerException)
- {
- }
-
- protected InvalidGifStreamException(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp.UnitTest/Api/Login/TestLoginInfo.cs b/src/BiliSharp.UnitTest/Api/Login/TestLoginInfo.cs
deleted file mode 100644
index 84c50d0..0000000
--- a/src/BiliSharp.UnitTest/Api/Login/TestLoginInfo.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using BiliSharp.Api.Login;
-
-namespace BiliSharp.UnitTest.Api.Login;
-
-public class TestLoginInfo
-{
- [Fact]
- public void TestGetNavigationInfo_Default()
- {
- Cookies.GetMyCookies();
-
- long mid = 42018135;
- var info = LoginInfo.GetNavigationInfo();
- Assert.Equal(mid, info.Data.Mid);
- }
-
- [Fact]
- public void TestGetLoginInfoStat_Default()
- {
- Cookies.GetMyCookies();
-
- var stat = LoginInfo.GetLoginInfoStat();
- Assert.NotNull(stat);
- }
-
- [Fact]
- public void TestGetMyCoin_Default()
- {
- Cookies.GetMyCookies();
-
- var coin = LoginInfo.GetMyCoin();
- Assert.NotNull(coin);
- }
-
-}
\ No newline at end of file
diff --git a/src/BiliSharp.UnitTest/Api/Login/TestLoginNotice.cs b/src/BiliSharp.UnitTest/Api/Login/TestLoginNotice.cs
deleted file mode 100644
index 1130ec4..0000000
--- a/src/BiliSharp.UnitTest/Api/Login/TestLoginNotice.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using BiliSharp.Api.Login;
-
-namespace BiliSharp.UnitTest.Api.Login;
-
-public class TestLoginNotice
-{
- [Fact]
- public void TestGetLoginNotice_Default()
- {
- Cookies.GetMyCookies();
-
- long mid = 42018135;
- var notice = LoginNotice.GetLoginNotice(mid);
- Assert.Equal(mid, notice.Data.Mid);
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp.UnitTest/Api/Login/TestLoginQR.cs b/src/BiliSharp.UnitTest/Api/Login/TestLoginQR.cs
deleted file mode 100644
index 4c21328..0000000
--- a/src/BiliSharp.UnitTest/Api/Login/TestLoginQR.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using BiliSharp.Api.Login;
-
-namespace BiliSharp.UnitTest.Api.Login;
-
-public class TestLoginQR
-{
- [Fact]
- public void TestGenerateQRCode_Default()
- {
- var qrcode = LoginQR.GenerateQRCode();
- Assert.NotNull(qrcode.Data);
- }
-
- [Fact]
- public void TestPollQRCode_Default()
- {
- var qrcode = LoginQR.GenerateQRCode();
- Assert.NotNull(qrcode.Data);
-
- var poll = LoginQR.PollQRCode(qrcode.Data.QrcodeKey);
- Assert.NotNull(poll.Data);
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp.UnitTest/Api/Sign/TestWbiSign.cs b/src/BiliSharp.UnitTest/Api/Sign/TestWbiSign.cs
deleted file mode 100644
index 93231b8..0000000
--- a/src/BiliSharp.UnitTest/Api/Sign/TestWbiSign.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-using BiliSharp.Api.Sign;
-
-namespace BiliSharp.UnitTest.Api.Sign
-{
- public class TestWbiSign
- {
- [Fact]
- public void TestParametersToQuery_Default()
- {
- var parameters = new Dictionary
- {
- { "fourk", 1 },
- { "fnver", 0 },
- { "fnval", 4048 },
- { "cid", 405595939 },
- { "qn", 120 },
- { "bvid", "BV1Sg411F7cb" },
- { "aid", 505421421 }
- };
- string expected = "fourk=1&fnver=0&fnval=4048&cid=405595939&qn=120&bvid=BV1Sg411F7cb&aid=505421421";
-
- string query = WbiSign.ParametersToQuery(parameters);
- Assert.Equal(expected, query);
- }
-
- [Fact]
- public void TestParametersToQuery_Empty()
- {
- var parameters = new Dictionary();
- string query = WbiSign.ParametersToQuery(parameters);
- Assert.Equal("", query);
- }
-
- [Fact]
- public void TestKeys_Default()
- {
- var key1 = WbiSign.GetKey();
- Assert.NotNull(key1);
-
- string imgKey = "34478ba821254d9d93542680e3b86100";
- string subKey = "7e16a90d190a4355a78fd00b32a38de6";
- var keys = new Tuple(imgKey, subKey);
- WbiSign.SetKey(keys);
-
- var key2 = WbiSign.GetKey();
- Assert.Equal(imgKey, key2.Item1);
- Assert.Equal(subKey, key2.Item2);
- }
-
- [Fact]
- public void TestEncodeWbi_Default()
- {
- var parameters = new Dictionary
- {
- { "fourk", 1 },
- { "fnver", 0 },
- { "fnval", 4048 },
- { "cid", 405595939 },
- { "qn", 120 },
- { "bvid", "BV1Sg411F7cb" },
- { "aid", 505421421 }
- };
-
- var wbi = WbiSign.EncodeWbi(parameters);
- Assert.NotNull(wbi["w_rid"]);
- }
-
- [Fact]
- public void TestEncodeWbi_Default2()
- {
- var parameters = new Dictionary
- {
- { "fourk", 1 },
- { "fnver", 0 },
- { "fnval", 4048 },
- { "cid", 405595939 },
- { "qn", 120 },
- { "bvid", "BV1Sg411F7cb" },
- { "aid", 505421421 }
- };
-
- var wbi = WbiSign.EncodeWbi(parameters, "653657f524a547ac981ded72ea172057", "6e4909c702f846728e64f6007736a338");
- Assert.NotNull(wbi["w_rid"]);
- }
-
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp.UnitTest/Api/User/TestNickname.cs b/src/BiliSharp.UnitTest/Api/User/TestNickname.cs
deleted file mode 100644
index 9712b06..0000000
--- a/src/BiliSharp.UnitTest/Api/User/TestNickname.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using BiliSharp.Api.User;
-
-namespace BiliSharp.UnitTest.Api.User
-{
- public class TestNickname
- {
- [Fact]
- public void TestCheckNickname_Default()
- {
- Equal("downkyi", 0);
- Equal("maozedong", 40002);
- Equal("//", 40004);
- Equal("test0000000000000", 40005);
- Equal("0", 40006);
- Equal("test", 40014);
- }
-
- private static void Equal(string nickname, int code)
- {
- var response = Nickname.CheckNickname(nickname);
- Assert.Equal(code, response.Code);
- }
-
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp.UnitTest/Api/User/TestUserInfo.cs b/src/BiliSharp.UnitTest/Api/User/TestUserInfo.cs
deleted file mode 100644
index 5b65f53..0000000
--- a/src/BiliSharp.UnitTest/Api/User/TestUserInfo.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using BiliSharp.Api.Login;
-using BiliSharp.Api.Sign;
-using BiliSharp.Api.User;
-
-namespace BiliSharp.UnitTest.Api.User
-{
- public class TestUserInfo
- {
- [Fact]
- public void TestGetUserInfo_Default()
- {
- Cookies.GetMyCookies();
-
- // 设置wbi keys
- var info = LoginInfo.GetNavigationInfo();
- var imgKey = info.Data.WbiImg.ImgUrl.Split('/').ToList().Last().Split('.')[0];
- var subKey = info.Data.WbiImg.SubUrl.Split('/').ToList().Last().Split('.')[0];
- var keys = new Tuple(imgKey, subKey);
- WbiSign.SetKey(keys);
-
- long mid = 42018135;
- var userInfo = UserInfo.GetUserInfo(mid);
-
- Assert.Equal(mid, userInfo.Data.Mid);
- }
-
- [Fact]
- public void TestGetUserCard_Default()
- {
- Cookies.GetMyCookies();
-
- long mid = 42018135;
- var userCard = UserInfo.GetUserCard(mid);
-
- Assert.Equal(mid.ToString(), userCard.Data.Card.Mid);
- }
-
- [Fact]
- public void TestGetMyInfo_Default()
- {
- Cookies.GetMyCookies();
-
- long mid = 42018135;
- var myInfo = UserInfo.GetMyInfo();
-
- Assert.Equal(mid, myInfo.Data.Mid);
- }
-
- [Fact]
- public void TestGetUserCards_Default()
- {
- Cookies.GetMyCookies();
-
- // https://api.vc.bilibili.com/account/v1/user/cards?uids=314521322,206840230,49246269
- List ids = new()
- {
- 314521322,
- 206840230,
- 49246269
- };
- var users = UserInfo.GetUserCards(ids);
-
- foreach (var user in users.Data)
- {
- Assert.Contains(user.Mid, ids);
- }
- }
-
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp.UnitTest/Api/Video/TestVideoInfo.cs b/src/BiliSharp.UnitTest/Api/Video/TestVideoInfo.cs
deleted file mode 100644
index 2ff7549..0000000
--- a/src/BiliSharp.UnitTest/Api/Video/TestVideoInfo.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using BiliSharp.Api.Login;
-using BiliSharp.Api.Sign;
-using BiliSharp.Api.Video;
-
-namespace BiliSharp.UnitTest.Api.Video
-{
- public class TestVideoInfo
- {
- [Fact]
- public void TestGetVideoViewInfo_Default()
- {
- // 设置wbi keys
- var info = LoginInfo.GetNavigationInfo();
- var imgKey = info.Data.WbiImg.ImgUrl.Split('/').ToList().Last().Split('.')[0];
- var subKey = info.Data.WbiImg.SubUrl.Split('/').ToList().Last().Split('.')[0];
- var keys = new Tuple(imgKey, subKey);
- WbiSign.SetKey(keys);
-
- string bvid = "BV1Pu4y1y7FA";
- long aid = 915570400;
- var videoInfo = VideoInfo.GetVideoViewInfo(bvid, aid);
-
- Assert.Equal(bvid, videoInfo.Data.View.Bvid);
- Assert.Equal(aid, videoInfo.Data.View.Aid);
- }
-
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp.UnitTest/BiliSharp.UnitTest.csproj b/src/BiliSharp.UnitTest/BiliSharp.UnitTest.csproj
deleted file mode 100644
index 93c83b6..0000000
--- a/src/BiliSharp.UnitTest/BiliSharp.UnitTest.csproj
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
- net7.0
- enable
- enable
-
- false
- true
-
-
-
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
-
-
-
-
-
-
diff --git a/src/BiliSharp.UnitTest/Cookies.cs b/src/BiliSharp.UnitTest/Cookies.cs
deleted file mode 100644
index f437dda..0000000
--- a/src/BiliSharp.UnitTest/Cookies.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System.Net;
-
-namespace BiliSharp.UnitTest;
-
-public static class Cookies
-{
- ///
- /// 解析从浏览器获取的cookies,用于设置cookie
- ///
- ///
- ///
- public static CookieContainer ParseCookieByString(string str)
- {
- var cookieContainer = new CookieContainer();
-
- var cookies = str.Replace(" ", "").Split(";");
- foreach (var cookie in cookies)
- {
- DateTime dateTime = DateTime.Now;
- dateTime = dateTime.AddMonths(12);
-
- var temp = cookie.Split("=");
- var name = temp[0];
- var value = temp[1];
-
- // 添加cookie
- cookieContainer.Add(new Cookie(name, value, "/", ".bilibili.com") { Expires = dateTime });
- }
- return cookieContainer;
- }
-
- public static void GetMyCookies()
- {
- string cookiesStr = "DedeUserID=42018135; " +
- "DedeUserID__ckMd5=44e22fa30fe34ac4; " +
- "SESSDATA=32c16297%2C1700815953%2Cb11cd%2A51; " +
- "bili_jct=98dbd091dc07d8f9b69ba3845974e7c8; " +
- "sid=6vomjg3u";
- var cookies = ParseCookieByString(cookiesStr);
- BiliManager.Instance().SetCookies(cookies);
- }
-
-}
diff --git a/src/BiliSharp.UnitTest/Usings.cs b/src/BiliSharp.UnitTest/Usings.cs
deleted file mode 100644
index 8c927eb..0000000
--- a/src/BiliSharp.UnitTest/Usings.cs
+++ /dev/null
@@ -1 +0,0 @@
-global using Xunit;
\ No newline at end of file
diff --git a/src/BiliSharp/Api/Login/LoginInfo.cs b/src/BiliSharp/Api/Login/LoginInfo.cs
deleted file mode 100644
index 6f204c2..0000000
--- a/src/BiliSharp/Api/Login/LoginInfo.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using BiliSharp.Api.Models.Login;
-
-namespace BiliSharp.Api.Login
-{
- ///
- /// 登录基本信息
- ///
- public static class LoginInfo
- {
- ///
- /// 导航栏用户信息
- ///
- ///
- public static NavigationLoginInfo GetNavigationInfo()
- {
- string url = "https://api.bilibili.com/x/web-interface/nav";
- return Utils.GetData(url);
- }
-
- ///
- /// 登录用户状态数(双端)
- ///
- ///
- public static LoginInfoStat GetLoginInfoStat()
- {
- string url = "https://api.bilibili.com/x/web-interface/nav/stat";
- return Utils.GetData(url);
- }
-
- ///
- /// 获取硬币数
- ///
- ///
- public static MyCoin GetMyCoin()
- {
- string url = "https://account.bilibili.com/site/getCoin";
- return Utils.GetData(url);
- }
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp/Api/Login/LoginNotice.cs b/src/BiliSharp/Api/Login/LoginNotice.cs
deleted file mode 100644
index c896248..0000000
--- a/src/BiliSharp/Api/Login/LoginNotice.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace BiliSharp.Api.Login
-{
- ///
- /// 登录记录
- ///
- public static class LoginNotice
- {
- ///
- /// 查询登录记录
- ///
- ///
- public static Models.Login.LoginNotice GetLoginNotice(long mid)
- {
- string url = $"https://api.bilibili.com/x/safecenter/login_notice?mid={mid}";
- return Utils.GetData(url);
- }
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp/Api/Login/LoginQR.cs b/src/BiliSharp/Api/Login/LoginQR.cs
deleted file mode 100644
index e5fc29b..0000000
--- a/src/BiliSharp/Api/Login/LoginQR.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using BiliSharp.Api.Models.Login;
-
-namespace BiliSharp.Api.Login
-{
- ///
- /// 二维码登录
- ///
- public static class LoginQR
- {
- ///
- /// 申请二维码(web端)
- ///
- ///
- public static LoginQRCode GenerateQRCode()
- {
- string url = "https://passport.bilibili.com/x/passport-login/web/qrcode/generate";
- return Utils.GetData(url);
- }
-
- ///
- /// 扫码登录(web端)
- ///
- ///
- public static LoginQRCodePoll PollQRCode(string qrcodeKey)
- {
- string url = $"https://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key={qrcodeKey}";
- return Utils.GetData(url);
- }
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp/Api/Models/Login/LoginInfoStat.cs b/src/BiliSharp/Api/Models/Login/LoginInfoStat.cs
deleted file mode 100644
index eaa79cc..0000000
--- a/src/BiliSharp/Api/Models/Login/LoginInfoStat.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using System.Text.Json.Serialization;
-
-namespace BiliSharp.Api.Models.Login
-{
- ///
- /// https://api.bilibili.com/x/web-interface/nav/stat
- ///
- public class LoginInfoStat
- {
- ///
- ///
- ///
- [JsonPropertyName("code")]
- public int Code { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("message")]
- public string Message { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("ttl")]
- public int Ttl { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("data")]
- public LoginInfoStatData Data { get; set; }
- }
-
- ///
- ///
- ///
- public class LoginInfoStatData
- {
- ///
- ///
- ///
- [JsonPropertyName("following")]
- public int Following { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("follower")]
- public int Follower { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("dynamic_count")]
- public int DynamicCount { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp/Api/Models/Login/LoginNotice.cs b/src/BiliSharp/Api/Models/Login/LoginNotice.cs
deleted file mode 100644
index 453c1bf..0000000
--- a/src/BiliSharp/Api/Models/Login/LoginNotice.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-using System.Text.Json.Serialization;
-
-namespace BiliSharp.Api.Models.Login
-{
- ///
- /// https://api.bilibili.com/x/safecenter/login_notice?mid=
- ///
- public class LoginNotice
- {
- ///
- ///
- ///
- [JsonPropertyName("code")]
- public int Code { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("message")]
- public string Message { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("ttl")]
- public int Ttl { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("data")]
- public LoginNoticeData Data { get; set; }
- }
-
- ///
- ///
- ///
- public class LoginNoticeData
- {
- ///
- ///
- ///
- [JsonPropertyName("mid")]
- public long Mid { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("device_name")]
- public string DeviceName { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("login_type")]
- public string LoginType { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("login_time")]
- public string LoginTime { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("location")]
- public string Location { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("ip")]
- public string Ip { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp/Api/Models/Login/LoginQRCode.cs b/src/BiliSharp/Api/Models/Login/LoginQRCode.cs
deleted file mode 100644
index 40921fb..0000000
--- a/src/BiliSharp/Api/Models/Login/LoginQRCode.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System.Text.Json.Serialization;
-
-namespace BiliSharp.Api.Models.Login
-{
- ///
- /// https://passport.bilibili.com/x/passport-login/web/qrcode/generate
- ///
- public class LoginQRCode
- {
- ///
- ///
- ///
- [JsonPropertyName("code")]
- public int Code { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("message")]
- public string Message { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("ttl")]
- public int Ttl { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("data")]
- public LoginQRCodeData Data { get; set; }
- }
-
- ///
- ///
- ///
- public class LoginQRCodeData
- {
- ///
- ///
- ///
- [JsonPropertyName("url")]
- public string Url { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("qrcode_key")]
- public string QrcodeKey { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp/Api/Models/Login/LoginQRCodePoll.cs b/src/BiliSharp/Api/Models/Login/LoginQRCodePoll.cs
deleted file mode 100644
index e183d69..0000000
--- a/src/BiliSharp/Api/Models/Login/LoginQRCodePoll.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using System.Text.Json.Serialization;
-
-namespace BiliSharp.Api.Models.Login
-{
- ///
- /// https://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key=
- ///
- public class LoginQRCodePoll
- {
- ///
- ///
- ///
- [JsonPropertyName("code")]
- public int Code { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("message")]
- public string Message { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("ttl")]
- public int Ttl { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("data")]
- public LoginQRCodePollData Data { get; set; }
- }
-
- ///
- ///
- ///
- public class LoginQRCodePollData
- {
- ///
- ///
- ///
- [JsonPropertyName("url")]
- public string Url { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("refresh_token")]
- public string RefreshToken { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("timestamp")]
- public long Timestamp { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("code")]
- public long Code { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("message")]
- public string Message { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp/Api/Models/Login/MyCoin.cs b/src/BiliSharp/Api/Models/Login/MyCoin.cs
deleted file mode 100644
index b7a9d7a..0000000
--- a/src/BiliSharp/Api/Models/Login/MyCoin.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System.Text.Json.Serialization;
-
-namespace BiliSharp.Api.Models.Login
-{
- ///
- /// https://account.bilibili.com/site/getCoin
- ///
- public class MyCoin
- {
- ///
- ///
- ///
- [JsonPropertyName("code")]
- public int Code { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("status")]
- public bool Status { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("data")]
- public MyCoinData Data { get; set; }
- }
-
- ///
- ///
- ///
- public class MyCoinData
- {
- ///
- ///
- ///
- [JsonPropertyName("money")]
- public int Money { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp/Api/Models/Login/NavigationLoginInfo.cs b/src/BiliSharp/Api/Models/Login/NavigationLoginInfo.cs
deleted file mode 100644
index 6475320..0000000
--- a/src/BiliSharp/Api/Models/Login/NavigationLoginInfo.cs
+++ /dev/null
@@ -1,556 +0,0 @@
-using System.Text.Json.Serialization;
-
-namespace BiliSharp.Api.Models.Login
-{
- ///
- /// https://api.bilibili.com/x/web-interface/nav
- ///
- public class NavigationLoginInfo
- {
- ///
- ///
- ///
- [JsonPropertyName("code")]
- public int Code { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("message")]
- public string Message { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("ttl")]
- public int Ttl { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("data")]
- public NavigationLoginInfoData Data { get; set; }
- }
-
- ///
- ///
- ///
- public class NavigationLoginInfoData
- {
- ///
- ///
- ///
- [JsonPropertyName("isLogin")]
- public bool Islogin { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("email_verified")]
- public int EmailVerified { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("face")]
- public string Face { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("face_nft")]
- public int FaceNft { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("face_nft_type")]
- public int FaceNftType { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("level_info")]
- public NavigationLoginInfoDataLevelInfo LevelInfo { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("mid")]
- public long Mid { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("mobile_verified")]
- public int MobileVerified { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("money")]
- public int Money { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("moral")]
- public int Moral { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("official")]
- public NavigationLoginInfoDataOfficial Official { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("officialVerify")]
- public NavigationLoginInfoDataOfficialverify Officialverify { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("pendant")]
- public NavigationLoginInfoDataPendant Pendant { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("scores")]
- public int Scores { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("uname")]
- public string Uname { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("vipDueDate")]
- public long Vipduedate { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("vipStatus")]
- public int Vipstatus { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("vipType")]
- public int Viptype { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("vip_pay_type")]
- public int VipPayType { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("vip_theme_type")]
- public int VipThemeType { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("vip_label")]
- public NavigationLoginInfoDataVipLabel VipLabel { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("vip_avatar_subscript")]
- public int VipAvatarSubscript { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("vip_nickname_color")]
- public string VipNicknameColor { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("vip")]
- public NavigationLoginInfoDataVip Vip { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("wallet")]
- public NavigationLoginInfoDataWallet Wallet { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("has_shop")]
- public bool HasShop { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("shop_url")]
- public string ShopUrl { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("allowance_count")]
- public int AllowanceCount { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("answer_status")]
- public int AnswerStatus { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("is_senior_member")]
- public int IsSeniorMember { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("wbi_img")]
- public NavigationLoginInfoDataWbiImg WbiImg { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("is_jury")]
- public bool IsJury { get; set; }
- }
-
- ///
- ///
- ///
- public class NavigationLoginInfoDataLevelInfo
- {
- ///
- ///
- ///
- [JsonPropertyName("current_level")]
- public int CurrentLevel { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("current_min")]
- public int CurrentMin { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("current_exp")]
- public int CurrentExp { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("next_exp")]
- public object NextExp { get; set; }
- }
-
- ///
- ///
- ///
- public class NavigationLoginInfoDataOfficial
- {
- ///
- ///
- ///
- [JsonPropertyName("role")]
- public int Role { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("title")]
- public string Title { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("desc")]
- public string Desc { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("type")]
- public int Type { get; set; }
- }
-
- ///
- ///
- ///
- public class NavigationLoginInfoDataOfficialverify
- {
- ///
- ///
- ///
- [JsonPropertyName("type")]
- public int Type { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("desc")]
- public string Desc { get; set; }
- }
-
- ///
- ///
- ///
- public class NavigationLoginInfoDataPendant
- {
- ///
- ///
- ///
- [JsonPropertyName("pid")]
- public int Pid { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("name")]
- public string Name { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("image")]
- public string Image { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("expire")]
- public int Expire { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("image_enhance")]
- public string ImageEnhance { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("image_enhance_frame")]
- public string ImageEnhanceFrame { get; set; }
- }
-
- ///
- ///
- ///
- public class NavigationLoginInfoDataVipLabel
- {
- ///
- ///
- ///
- [JsonPropertyName("path")]
- public string Path { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("text")]
- public string Text { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("label_theme")]
- public string LabelTheme { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("text_color")]
- public string TextColor { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("bg_style")]
- public int BgStyle { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("bg_color")]
- public string BgColor { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("border_color")]
- public string BorderColor { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("use_img_label")]
- public bool UseImgLabel { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("img_label_uri_hans")]
- public string ImgLabelUriHans { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("img_label_uri_hant")]
- public string ImgLabelUriHant { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("img_label_uri_hans_static")]
- public string ImgLabelUriHansStatic { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("img_label_uri_hant_static")]
- public string ImgLabelUriHantStatic { get; set; }
- }
-
- ///
- ///
- ///
- public class NavigationLoginInfoDataVip
- {
- ///
- ///
- ///
- [JsonPropertyName("type")]
- public int Type { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("status")]
- public int Status { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("due_date")]
- public long DueDate { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("vip_pay_type")]
- public int VipPayType { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("theme_type")]
- public int ThemeType { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("label")]
- public NavigationLoginInfoDataVipLabel Label { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("avatar_subscript")]
- public int AvatarSubscript { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("nickname_color")]
- public string NicknameColor { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("role")]
- public int Role { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("avatar_subscript_url")]
- public string AvatarSubscriptUrl { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("tv_vip_status")]
- public int TvVipStatus { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("tv_vip_pay_type")]
- public int TvVipPayType { get; set; }
- }
-
- ///
- ///
- ///
- public class NavigationLoginInfoDataWallet
- {
- ///
- ///
- ///
- [JsonPropertyName("mid")]
- public long Mid { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("bcoin_balance")]
- public int BcoinBalance { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("coupon_balance")]
- public int CouponBalance { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("coupon_due_time")]
- public int CouponDueTime { get; set; }
- }
-
- ///
- ///
- ///
- public class NavigationLoginInfoDataWbiImg
- {
- ///
- ///
- ///
- [JsonPropertyName("img_url")]
- public string ImgUrl { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("sub_url")]
- public string SubUrl { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp/Api/Models/User/MyInfo.cs b/src/BiliSharp/Api/Models/User/MyInfo.cs
deleted file mode 100644
index cfb71cd..0000000
--- a/src/BiliSharp/Api/Models/User/MyInfo.cs
+++ /dev/null
@@ -1,652 +0,0 @@
-using System.Text.Json.Serialization;
-
-namespace BiliSharp.Api.Models.User
-{
- ///
- /// https://api.bilibili.com/x/space/myinfo
- ///
- public class MyInfo
- {
- ///
- ///
- ///
- [JsonPropertyName("code")]
- public int Code { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("message")]
- public string Message { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("ttl")]
- public int Ttl { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("data")]
- public MyInfoData Data { get; set; }
- }
-
- ///
- ///
- ///
- public class MyInfoData
- {
- ///
- ///
- ///
- [JsonPropertyName("mid")]
- public long Mid { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("name")]
- public string Name { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("sex")]
- public string Sex { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("face")]
- public string Face { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("sign")]
- public string Sign { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("rank")]
- public int Rank { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("level")]
- public int Level { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("jointime")]
- public int Jointime { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("moral")]
- public int Moral { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("silence")]
- public int Silence { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("email_status")]
- public int EmailStatus { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("tel_status")]
- public int TelStatus { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("identification")]
- public int Identification { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("vip")]
- public MyInfoDataVip Vip { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("pendant")]
- public MyInfoDataPendant Pendant { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("nameplate")]
- public MyInfoDataNameplate Nameplate { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("official")]
- public MyInfoDataOfficial Official { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("birthday")]
- public long Birthday { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("is_tourist")]
- public int IsTourist { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("is_fake_account")]
- public int IsFakeAccount { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("pin_prompting")]
- public int PinPrompting { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("is_deleted")]
- public int IsDeleted { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("in_reg_audit")]
- public int InRegAudit { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("is_rip_user")]
- public bool IsRipUser { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("profession")]
- public MyInfoDataProfession Profession { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("face_nft")]
- public int FaceNft { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("face_nft_new")]
- public int FaceNftNew { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("is_senior_member")]
- public int IsSeniorMember { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("honours")]
- public MyInfoDataHonours Honours { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("digital_id")]
- public string DigitalId { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("digital_type")]
- public int DigitalType { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("level_exp")]
- public MyInfoDataLevelExp LevelExp { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("coins")]
- public int Coins { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("following")]
- public int Following { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("follower")]
- public int Follower { get; set; }
- }
-
- ///
- ///
- ///
- public class MyInfoDataVip
- {
- ///
- ///
- ///
- [JsonPropertyName("type")]
- public int Type { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("status")]
- public int Status { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("due_date")]
- public long DueDate { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("vip_pay_type")]
- public int VipPayType { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("theme_type")]
- public int ThemeType { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("label")]
- public MyInfoDataVipLabel Label { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("avatar_subscript")]
- public int AvatarSubscript { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("nickname_color")]
- public string NicknameColor { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("role")]
- public int Role { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("avatar_subscript_url")]
- public string AvatarSubscriptUrl { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("tv_vip_status")]
- public int TvVipStatus { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("tv_vip_pay_type")]
- public int TvVipPayType { get; set; }
- }
-
- ///
- ///
- ///
- public class MyInfoDataVipLabel
- {
- ///
- ///
- ///
- [JsonPropertyName("path")]
- public string Path { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("text")]
- public string Text { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("label_theme")]
- public string LabelTheme { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("text_color")]
- public string TextColor { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("bg_style")]
- public int BgStyle { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("bg_color")]
- public string BgColor { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("border_color")]
- public string BorderColor { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("use_img_label")]
- public bool UseImgLabel { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("img_label_uri_hans")]
- public string ImgLabelUriHans { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("img_label_uri_hant")]
- public string ImgLabelUriHant { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("img_label_uri_hans_static")]
- public string ImgLabelUriHansStatic { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("img_label_uri_hant_static")]
- public string ImgLabelUriHantStatic { get; set; }
- }
-
- ///
- ///
- ///
- public class MyInfoDataPendant
- {
- ///
- ///
- ///
- [JsonPropertyName("pid")]
- public int Pid { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("name")]
- public string Name { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("image")]
- public string Image { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("expire")]
- public int Expire { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("image_enhance")]
- public string ImageEnhance { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("image_enhance_frame")]
- public string ImageEnhanceFrame { get; set; }
- }
-
- ///
- ///
- ///
- public class MyInfoDataNameplate
- {
- ///
- ///
- ///
- [JsonPropertyName("nid")]
- public int Nid { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("name")]
- public string Name { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("image")]
- public string Image { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("image_small")]
- public string ImageSmall { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("level")]
- public string Level { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("condition")]
- public string Condition { get; set; }
- }
-
- ///
- ///
- ///
- public class MyInfoDataOfficial
- {
- ///
- ///
- ///
- [JsonPropertyName("role")]
- public int Role { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("title")]
- public string Title { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("desc")]
- public string Desc { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("type")]
- public int Type { get; set; }
- }
-
- ///
- ///
- ///
- public class MyInfoDataProfession
- {
- ///
- ///
- ///
- [JsonPropertyName("id")]
- public int Id { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("name")]
- public string Name { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("show_name")]
- public string ShowName { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("is_show")]
- public int IsShow { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("category_one")]
- public string CategoryOne { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("realname")]
- public string Realname { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("title")]
- public string Title { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("department")]
- public string Department { get; set; }
- }
-
- ///
- ///
- ///
- public class MyInfoDataHonours
- {
- ///
- ///
- ///
- [JsonPropertyName("mid")]
- public long Mid { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("colour")]
- public MyInfoDataHonoursColour Colour { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("tags")]
- public object Tags { get; set; }
- }
-
- ///
- ///
- ///
- public class MyInfoDataHonoursColour
- {
- ///
- ///
- ///
- [JsonPropertyName("dark")]
- public string Dark { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("normal")]
- public string Normal { get; set; }
- }
-
- ///
- ///
- ///
- public class MyInfoDataLevelExp
- {
- ///
- ///
- ///
- [JsonPropertyName("current_level")]
- public int CurrentLevel { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("current_min")]
- public int CurrentMin { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("current_exp")]
- public int CurrentExp { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("next_exp")]
- public int NextExp { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("level_up")]
- public long LevelUp { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp/Api/Models/User/Nickname.cs b/src/BiliSharp/Api/Models/User/Nickname.cs
deleted file mode 100644
index 8c08569..0000000
--- a/src/BiliSharp/Api/Models/User/Nickname.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.Text.Json.Serialization;
-
-namespace BiliSharp.Api.Models.User
-{
- ///
- /// https://passport.bilibili.com/web/generic/check/nickname?nickName=hahaha
- ///
- public class Nickname
- {
- ///
- ///
- ///
- [JsonPropertyName("code")]
- public int Code { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("message")]
- public string Message { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/BiliSharp/Api/Models/User/UserCard.cs b/src/BiliSharp/Api/Models/User/UserCard.cs
deleted file mode 100644
index 090b0c3..0000000
--- a/src/BiliSharp/Api/Models/User/UserCard.cs
+++ /dev/null
@@ -1,599 +0,0 @@
-using System.Collections.Generic;
-using System.Text.Json.Serialization;
-
-namespace BiliSharp.Api.Models.User
-{
- ///
- /// https://api.bilibili.com/x/web-interface/card?mid=314521322&photo=true
- ///
- public class UserCard
- {
- ///
- ///
- ///
- [JsonPropertyName("code")]
- public int Code { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("message")]
- public string Message { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("ttl")]
- public int Ttl { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("data")]
- public UserCardData Data { get; set; }
- }
-
- ///
- ///
- ///
- public class UserCardData
- {
- ///
- ///
- ///
- [JsonPropertyName("card")]
- public UserCardDataCard Card { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("space")]
- public UserCardDataSpace Space { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("following")]
- public bool Following { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("archive_count")]
- public int ArchiveCount { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("article_count")]
- public int ArticleCount { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("follower")]
- public long Follower { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("like_num")]
- public long LikeNum { get; set; }
- }
-
- ///
- ///
- ///
- public class UserCardDataCard
- {
- ///
- ///
- ///
- [JsonPropertyName("mid")]
- public string Mid { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("name")]
- public string Name { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("approve")]
- public bool Approve { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("sex")]
- public string Sex { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("rank")]
- public string Rank { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("face")]
- public string Face { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("face_nft")]
- public int FaceNft { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("face_nft_type")]
- public int FaceNftType { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("DisplayRank")]
- public string Displayrank { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("regtime")]
- public int Regtime { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("spacesta")]
- public int Spacesta { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("birthday")]
- public string Birthday { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("place")]
- public string Place { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("description")]
- public string Description { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("article")]
- public int Article { get; set; }
-
- ///
- ///
- ///
- [JsonPropertyName("attentions")]
- public List