Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

Commit

Permalink
Added timer to discord presence, added Season and Episode number to p…
Browse files Browse the repository at this point in the history
…resence and little ascii playback symbol
  • Loading branch information
Dominik Hrinkino committed Aug 30, 2021
1 parent 2ee35dd commit 9346fb6
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions Plex Discord Presence/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public partial class Form1 : Form
private DiscordRpcClient client;
private int tick = 0;
private bool status = false;
private dynamic now = DateTime.UtcNow;
private bool detected = false;
public Form1()
{
InitializeComponent();
Expand Down Expand Up @@ -94,29 +96,40 @@ private bool GetPlexData()
string text_second = null;
if (stuff["MediaContainer"]["@size"] > 1)
{
if (detected == false)
{
// setting new datetime
now = DateTime.UtcNow;
detected = !detected;
}

if (stuff["MediaContainer"]["Video"][0]["@type"] == "movie")
{
text = stuff["MediaContainer"]["Video"][0]["@title"];
text = "▶ " + stuff["MediaContainer"]["Video"][0]["@title"];

}
else
{
text = stuff["MediaContainer"]["Video"][0]["@grandparentTitle"] + " " + stuff["MediaContainer"]["Video"][0]["@title"];
text = "▶ " + stuff["MediaContainer"]["Video"][0]["@grandparentTitle"];
text_second = "S" + int.Parse(stuff["MediaContainer"][0]["Video"]["@parentIndex"].ToString()).ToString("00") + "E" + int.Parse(stuff["MediaContainer"]["Video"][0]["@index"].ToString()).ToString("00") + " " + stuff["MediaContainer"]["Video"][0]["@title"];
}

}
else
{
if (stuff["MediaContainer"]["Video"]["@type"] == "movie")
{
text = stuff["MediaContainer"]["Video"]["@title"];
// Movie
text = "▶ " + stuff["MediaContainer"]["Video"]["@title"];
text_second = "";

}
else
{
text = stuff["MediaContainer"]["Video"]["@grandparentTitle"];
text_second = stuff["MediaContainer"]["Video"]["@title"];

// TV Show
text = "▶ " + stuff["MediaContainer"]["Video"]["@grandparentTitle"];
text_second = "S"+ int.Parse(stuff["MediaContainer"]["Video"]["@parentIndex"].ToString()).ToString("00") + "E" + int.Parse(stuff["MediaContainer"]["Video"]["@index"].ToString()).ToString("00") + " "+ stuff["MediaContainer"]["Video"]["@title"];
}

}
Expand All @@ -134,9 +147,11 @@ private bool GetPlexData()
}
else
{
detected = false;
label1.Text = "Nothing Playing";
label5.Text = "";
client.ClearPresence();
now = DateTime.UtcNow;
}

return true;
Expand All @@ -148,8 +163,10 @@ private void UpdatePresence(string Details, string State,Assets PlexData)
{
Details = Details,
State = State,
Assets = PlexData
Assets = PlexData,
Timestamps = new Timestamps(now)
});

}

private void Form1_Load(object sender, EventArgs e)
Expand All @@ -174,6 +191,7 @@ private void button1_Click_1(object sender, EventArgs e)
else
{
timer1.Stop();
detected = false;
client.ClearPresence();
status = !status;
button1.Text = "Run";
Expand Down

0 comments on commit 9346fb6

Please sign in to comment.