Exemple #1
0
 public void ExtractSeriesContentId(string urlOrId)
 {
     if (Uri.TryCreate(urlOrId, UriKind.Absolute, out var uri))
     {
         CheckExtractIdResult(NiconicoIdType.Series, NiconicoUrls.ExtractNicoContentId(uri));
     }
     else
     {
         CheckExtractIdResult(NiconicoIdType.Series, new NiconicoId(urlOrId));
     }
 }
Exemple #2
0
 public void ExtractVideoContentId(string urlOrId)
 {
     if (Uri.TryCreate(urlOrId, UriKind.Absolute, out var uri))
     {
         var id = NiconicoUrls.ExtractNicoContentId(uri);
         Assert.IsNotNull(id);
         Assert.IsTrue(id.Value.IdType is NiconicoIdType.Video or NiconicoIdType.Video);
     }
     else
     {
         Assert.IsTrue(NiconicoId.TryCreate(urlOrId, out var id));
         Assert.IsTrue(id.IdType is NiconicoIdType.Video or NiconicoIdType.Video);
     }
 }
Exemple #3
0
        static public async Task <NiconicoId?> CheckClipboard()
        {
            DataPackageView dataPackageView = Clipboard.GetContent();

            if (dataPackageView.Contains(StandardDataFormats.WebLink))
            {
                var uri = await dataPackageView.GetWebLinkAsync();

                if (uri.OriginalString == prevContent)
                {
                    return(null);
                }

                prevContent = uri.OriginalString;
                return(NiconicoUrls.ExtractNicoContentId(uri));
            }
            else if (dataPackageView.Contains(StandardDataFormats.Text))
            {
                string text = await dataPackageView.GetTextAsync();

                if (prevContent == text)
                {
                    return(null);
                }
                prevContent = text;
                try
                {
                    if (Uri.TryCreate(text, UriKind.Absolute, out var uri))
                    {
                        return(NiconicoUrls.ExtractNicoContentId(uri));
                    }
                    else
                    {
                        return(NiconicoId.TryCreate(text, out var id) ? id : null);
                    }
                }
                catch
                {
                }
            }

            return(null);
        }