<commit_before>﻿using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.Azure.WebJobs;

namespace AzureBackgroundApplication
{
	public class Program
	{
		private static void Main(string[] args)
		{
			JobHost host = new JobHost();
			host.RunAndBlock();
		}

		/// <summary>
		/// YouTube 동영상 주소로부터 이미지를 취득. 링크가 2개일 경우 좌우병합.
		/// </summary>
		/// <param name="input"></param>
		/// <param name="BlobFilename"></param>
		/// <param name="writer"></param>
		public static void ProcessQueueMessage([QueueTrigger("webjobsqueue")] YoutubeLink input, string BlobFilename,
			[Blob("tagboa/{BlobFilename}", FileAccess.Write)] Stream writer)
		{
			if (input.Links.Length == 1)
			{
				using (HttpClient client = new HttpClient())
				{
					var url = getVideoCode(input.Links[0]);
					using (HttpResponseMessage response = client.GetAsync(url).Result)
					{
						if (response.IsSuccessStatusCode)
						{
							using (HttpContent content = response.Content)
							{
								var image = content.ReadAsByteArrayAsync().Result;
								writer.Write(image, 0, image.Length);
							}
						}
						else
							Console.WriteLine("cannot get from " + url);
					}
				}
			}
			else if (input.Links.Length == 2)
			{
				string[] links = input.Links.Select(getVideoCode).ToArray();
				var messageBytes = ImageToByte(mergeImages(links));

				writer.Write(messageBytes, 0, messageBytes.Length);
			}
			else
			{
				byte[] errorOutput = Encoding.UTF8.GetBytes("error");
				writer.WriteAsync(errorOutput, 0, errorOutput.Length).Wait();
			}
		}

		public static void ProcessQueueMessage([QueueTrigger("webjobsqueue")] YoutubeLink input)
		{
			Console.WriteLine("애저찡 사랑해 :)");
		}

		/// <summary><commit_msg>deletion test<commit_after>﻿using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.Azure.WebJobs;

namespace AzureBackgroundApplication
{
	public class Program
	{
		private static void Main(string[] args)
		{
			JobHost host = new JobHost();
			host.RunAndBlock();
		}

		/// <summary>
		/// YouTube 동영상 주소로부터 이미지를 취득. 링크가 2개일 경우 좌우병합.
		/// </summary>
		/// <param name="input"></param>
		/// <param name="BlobFilename"></param>
		/// <param name="writer"></param>
		public static void ProcessQueueMessage([QueueTrigger("webjobsqueue")] YoutubeLink input, 
			string BlobFilename,
			[Blob("tagboa/{BlobFilename}", FileAccess.Write)] Stream writer)
		{
			if (input.Links.Length == 1)
			{
				using (HttpClient client = new HttpClient())
				{
					var url = getVideoCode(input.Links[0]);
					using (HttpResponseMessage response = client.GetAsync(url).Result)
					{
						if (response.IsSuccessStatusCode)
						{
							using (HttpContent content = response.Content)
							{
								var image = content.ReadAsByteArrayAsync().Result;
								writer.Write(image, 0, image.Length);
							}
						}
						else
							Console.Out.WriteLine("cannot get from " + url);
					}
				}
			}
			else if (input.Links.Length == 2)
			{
				string[] links = input.Links.Select(getVideoCode).ToArray();
				var messageBytes = ImageToByte(mergeImages(links));

				writer.Write(messageBytes, 0, messageBytes.Length);
			}
			else
			{
				byte[] errorOutput = Encoding.UTF8.GetBytes("error");
				writer.WriteAsync(errorOutput, 0, errorOutput.Length).Wait();
			}
			Console.Out.WriteLine("완료 :)");

		}

		public static void WriteLog([QueueTrigger("webjobsqueue")] YoutubeLink input)
		{
			Console.Out.WriteLine("애저찡 사랑해 :)");
		}

		/// <summary>
{'fraction_non_alphanumeric': 0.13872989915508313, 'fraction_numerical': 0.004360861270100845, 'mean_word_length': 3.228110599078341, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1558937', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1223, 'n_words': 243}