Upload files to "/"
Gitea Actions Demo / Explore-Gitea-Actions (8.0.x) (push) Failing after 1m22s

This commit is contained in:
2025-06-09 17:18:30 +00:00
parent a0124a9313
commit 44508acf2b
2 changed files with 97 additions and 190 deletions
+70 -163
View File
@@ -1,190 +1,97 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using static System.Net.Mime.MediaTypeNames;
using System.Collections.Generic;
using System.Data.SQLite;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Simpsons_generator;
class Program
{
/* public static void openit(string x) {
System.Diagnostics.Process.Start("cmd", "/C start" + " " + x);
}*/
public static readonly string root_path = "C:\\Users\\pgeeraert\\OneDrive - Prometheus Group\\Documents\\Code\\SQLLITE\\";
public static readonly string folder_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Simpsons_generator");
public static readonly string filePath = Path.Combine(folder_path, "episodes-watched.csv");
public static readonly string overrideBrowser = Path.Combine(folder_path, "overrideBrowser.xml");
private static void openit(string url)
static SQLiteConnection CreateConnection()
{
SQLiteConnection sqliteconn;
// Create a new database connection:
var sqllite_datasource = $"Data Source={folder_path}/database.db;Version=3;New=True;Compress=True;";
sqliteconn = new SQLiteConnection(sqllite_datasource);
// Open the connection:
try
{
Process.Start(url);
sqliteconn.Open();
}
catch
{
// hack because of this: https://github.com/dotnet/corefx/issues/10361
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
url = url.Replace("&", "^&");
if (File.Exists(overrideBrowser))
{
string browser_path = File.ReadAllText(overrideBrowser);
Console.WriteLine("browser: "+browser_path);
Process.Start(new ProcessStartInfo(browser_path, url) { CreateNoWindow = true });
}
else {
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
}
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Process.Start("xdg-open", url);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Process.Start("open", url);
}
else
{
throw;
}
}
//Process.Start(new ProcessStartInfo("C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe", url_generated) { CreateNoWindow = true });
}
private static bool CheckEpisodeAlreadyRun(string url)
{
if (File.Exists(filePath))
catch (Exception ex)
{
var linesRead = File.ReadLines(filePath);
// iterate through each element within the array and
// print it out
//
foreach (var lineRead in linesRead)
{
if (lineRead == url)
{
Console.WriteLine("already watched");
return true;
}
}
}
return false;
}
private static void saveIntoFile(string data_input)
{
//first check if folder and file exist
if (!Directory.Exists(folder_path))
Directory.CreateDirectory(folder_path);
using (StreamWriter w = new StreamWriter(filePath, true))
{
w.WriteLine(data_input);
}
return sqliteconn;
}
static void Main(string[] args)
{
SQLiteConnection sqliteconn;
sqliteconn = CreateConnection();
//CreateTableSimpsons(sqliteconn);
//InsertDataSimpsons(sqliteconn);
//readexcel(Path.Combine(root_path, "simpsons-episodes-list.xlsx"));
ReadData(sqliteconn);
}
string url_generated;
static void readexcel(string filePath)
{
var linesRead = File.ReadLines(filePath);
bool restart = false;
do
// iterate through each element within the array and
// print it out
//
foreach (var lineRead in linesRead)
{
restart = false;
int maximum_number_seasons = 35;
string root_url = "https://kisscartoon.top/episode/the-simpsons-season-";
//random for the season
Random rnd = new Random();
int random_season = rnd.Next(1, maximum_number_seasons);
Console.WriteLine("random season:"+random_season);
//dictionary for the maximum number of episodes
Dictionary<int, int> Season_nbr_Episodes = new Dictionary<int, int>();
Season_nbr_Episodes.Add(1,13);
Season_nbr_Episodes.Add(2,22);
Season_nbr_Episodes.Add(3,24);
Season_nbr_Episodes.Add(4,22);
Season_nbr_Episodes.Add(5,22);
Season_nbr_Episodes.Add(6,25);
Season_nbr_Episodes.Add(7,25);
Season_nbr_Episodes.Add(8,25);
Season_nbr_Episodes.Add(9,25);
Season_nbr_Episodes.Add(10,23);
Season_nbr_Episodes.Add(11,22);
Season_nbr_Episodes.Add(12,21);
Season_nbr_Episodes.Add(13,22);
Season_nbr_Episodes.Add(14,22);
Season_nbr_Episodes.Add(15,22);
Season_nbr_Episodes.Add(16,21);
Season_nbr_Episodes.Add(17,22);
Season_nbr_Episodes.Add(18,22);
Season_nbr_Episodes.Add(19,20);
Season_nbr_Episodes.Add(20,21);
Season_nbr_Episodes.Add(21,23);
Season_nbr_Episodes.Add(22,22);
Season_nbr_Episodes.Add(23,22);
Season_nbr_Episodes.Add(24,22);
Season_nbr_Episodes.Add(25,22);
Season_nbr_Episodes.Add(26,22);
Season_nbr_Episodes.Add(27,22);
Season_nbr_Episodes.Add(28,22);
Season_nbr_Episodes.Add(29,21);
Season_nbr_Episodes.Add(30,23);
Season_nbr_Episodes.Add(31,22);
Season_nbr_Episodes.Add(32,22);
Season_nbr_Episodes.Add(33,22);
Season_nbr_Episodes.Add(34,22);
Season_nbr_Episodes.Add(35,18);
int random_episode = rnd.Next(1,Season_nbr_Episodes[random_season]);
Console.WriteLine("random episode:"+random_episode);
//url generated
url_generated = root_url + random_season + "-episode-"+random_episode;
Console.WriteLine(url_generated);
if (CheckEpisodeAlreadyRun(url_generated))
{
//return;
restart = true;
Console.WriteLine("already watched");
}
} while (restart);
openit(url_generated);
saveIntoFile(url_generated);
Console.WriteLine(lineRead);
}
}
static void CreateTableSimpsons(SQLiteConnection conn)
{
SQLiteCommand sqlite_cmd;
string Createsql = "CREATE TABLE episodes(season int(3), episode INT(3),url VARCHAR(100),seen INT(1))";
sqlite_cmd = conn.CreateCommand();
sqlite_cmd.CommandText = Createsql;
sqlite_cmd.ExecuteNonQuery();
}
static void InsertDataSimpsons(SQLiteConnection conn)
{
SQLiteCommand sqlite_cmd;
sqlite_cmd = conn.CreateCommand();
sqlite_cmd.CommandText = "INSERT INTO episodes(season, episode,url,seen) VALUES (1,1,'https://kisscartoon.sh/Cartoon/The-Simpsons-Season-01.47729/Episode-001?id=1072', 0);";
sqlite_cmd.ExecuteNonQuery();
}
static void ReadData(SQLiteConnection conn)
{
SQLiteDataReader sqlite_datareader;
SQLiteCommand sqlite_cmd;
sqlite_cmd = conn.CreateCommand();
sqlite_cmd.CommandText = "SELECT * FROM episodes";
sqlite_datareader = sqlite_cmd.ExecuteReader();
while (sqlite_datareader.Read())
{
int season = Convert.ToInt32(sqlite_datareader["season"]);
int episode = Convert.ToInt32(sqlite_datareader["episode"]);
string url = sqlite_datareader["url"].ToString();
string seen = sqlite_datareader["seen"].ToString();
Console.WriteLine($"{season}, {episode}, {url}, {seen}");
}
conn.Close();
}
}
BIN
View File
Binary file not shown.