<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace VideoLibrary
{
    public partial class Video
    {
        /// <summary>
        /// Initializes a new instance of the VideoLibrary.Video class.
        /// </summary>
        /// <param name="title">The video title.</param>
        /// <param name="uri">The video URI.</param>
        /// <param name="webSite">The name of the video's website, i.e. "YouTube".</param>
        public Video(string title, 
            string uri, string webSite)
            : this(title, uri, webSite, -1)
        { }

        /// <summary>
        /// Initializes a new instance of the VideoLibrary.Video class.
        /// </summary>
        /// <param name="title">The video title.</param>
        /// <param name="uri">The URI where the video can be downloaded.</param>
        /// <param name="webSite">The name of the video's website, i.e. "YouTube".</param>
        /// <param name="formatCode">YouTube-only. The format code of the video, used internally to determine properties such as bitrate and resolution. If the code is unknown or not applicable, -1.</param>
        public Video(string title, string uri, 
            string webSite, int formatCode)
        {
            this.Uri = uri;
            this.Title = title;
            this.WebSite = webSite;
            this.FormatCode = formatCode;
        }

        /// <summary>
        /// The URI where the video can be downloaded.
        /// </summary>
        public string Uri { get; }
        /// <summary>
        /// The video's title.
        /// </summary>
        public string Title { get; }
        /// <summary>
        /// The name of the website where the video came from. Videos coming from this library should have a WebSite matching one of the constants in static class WebSites.
        /// </summary>
        public string WebSite { get; }

        /// <summary>
        /// YouTube-only. The format code of the video, used internally to determine properties such as bitrate and resolution. If the code is unknown or not applicable, -1.
        /// </summary>
        public int FormatCode { get; }

        /// <summary>
        /// Gets the byte array representing the video's file.
        /// </summary>
        /// <returns>The bytes of the video, which are generally saved into a file.</returns>
        public byte[] GetBytes() =>
            GetBytesAsync().Result;

        /// <summary>
        /// Gets the byte array representing the video's file as an asynchronous operation.
        /// </summary>
        /// <returns>A Task returning the bytes of the video, which are generally saved into a file.</returns>
        public async Task<byte[]> GetBytesAsync()
        {
            using (var client = new HttpClient())
            {
                return await client
                    .GetByteArrayAsync(Uri)
                    .ConfigureAwait(false);
            }
        }

        public Stream Stream() =>
            StreamAsync().Result;

        public async Task<Stream> StreamAsync()
        {
            using (var client = new HttpClient())
            {
                return await client
                    .GetStreamAsync(Uri)
                    .ConfigureAwait(false);
            }
        }

        public string FullName => Title + FileExtension;

        public override string ToString() => FullName;
    }
}<commit_msg>Remove invalid filename chars from FullName<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace VideoLibrary
{
    public partial class Video
    {
        /// <summary>
        /// Initializes a new instance of the VideoLibrary.Video class.
        /// </summary>
        /// <param name="title">The video title.</param>
        /// <param name="uri">The video URI.</param>
        /// <param name="webSite">The name of the video's website, i.e. "YouTube".</param>
        public Video(string title, 
            string uri, string webSite)
            : this(title, uri, webSite, -1)
        { }

        /// <summary>
        /// Initializes a new instance of the VideoLibrary.Video class.
        /// </summary>
        /// <param name="title">The video title.</param>
        /// <param name="uri">The URI where the video can be downloaded.</param>
        /// <param name="webSite">The name of the video's website, i.e. "YouTube".</param>
        /// <param name="formatCode">YouTube-only. The format code of the video, used internally to determine properties such as bitrate and resolution. If the code is unknown or not applicable, -1.</param>
        public Video(string title, string uri, 
            string webSite, int formatCode)
        {
            this.Uri = uri;
            this.Title = title;
            this.WebSite = webSite;
            this.FormatCode = formatCode;
        }

        /// <summary>
        /// The URI where the video can be downloaded.
        /// </summary>
        public string Uri { get; }
        /// <summary>
        /// The video's title.
        /// </summary>
        public string Title { get; }
        /// <summary>
        /// The name of the website where the video came from. Videos coming from this library should have a WebSite matching one of the constants in static class WebSites.
        /// </summary>
        public string WebSite { get; }

        /// <summary>
        /// YouTube-only. The format code of the video, used internally to determine properties such as bitrate and resolution. If the code is unknown or not applicable, -1.
        /// </summary>
        public int FormatCode { get; }

        /// <summary>
        /// Gets the byte array representing the video's file.
        /// </summary>
        /// <returns>The bytes of the video, which are generally saved into a file.</returns>
        public byte[] GetBytes() =>
            GetBytesAsync().Result;

        /// <summary>
        /// Gets the byte array representing the video's file as an asynchronous operation.
        /// </summary>
        /// <returns>A Task returning the bytes of the video, which are generally saved into a file.</returns>
        public async Task<byte[]> GetBytesAsync()
        {
            using (var client = new HttpClient())
            {
                return await client
                    .GetByteArrayAsync(Uri)
                    .ConfigureAwait(false);
            }
        }

        public Stream Stream() =>
            StreamAsync().Result;

        public async Task<Stream> StreamAsync()
        {
            using (var client = new HttpClient())
            {
                return await client
                    .GetStreamAsync(Uri)
                    .ConfigureAwait(false);
            }
        }

        public string FullName
        {
            get
            {
                string result = Title + FileExtension;

                foreach (char bad in Path.GetInvalidFileNameChars())
                    result = result.Replace(bad.ToString(), string.Empty);

                return result;
            }
        }

        public override string ToString() => FullName;
    }
}
{'fraction_non_alphanumeric': 0.10912806539509537, 'fraction_numerical': 0.0008174386920980927, 'mean_word_length': 1.6929567131327954, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 82, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6473018', 'n_tokens_mistral': 1843, 'n_tokens_neox': 1775, 'n_words': 658}