Skip to content

Commit

Permalink
Added support for timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
thepwrtank18 committed Feb 1, 2023
1 parent 4dbbe8a commit 4a18ceb
Show file tree
Hide file tree
Showing 9 changed files with 4,757 additions and 12 deletions.
2 changes: 1 addition & 1 deletion GetLink.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33103.184
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetLink", "GetLink\GetLink.csproj", "{4EB8BDA6-68AC-491F-8EA8-B8C09A46B951}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetLink", "GetLink\GetLink.csproj", "{4EB8BDA6-68AC-491F-8EA8-B8C09A46B951}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
22 changes: 12 additions & 10 deletions GetLink/Controllers/GetM3UController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ public string GetM3U(string seriesId, string? authToken = null, string? username
}

var httpResponse2 = (HttpWebResponse)httpRequest2.GetResponse();
using (var streamReader = new StreamReader(httpResponse2.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
var test = JsonConvert.DeserializeObject<dynamic>(result);
authToken = test.AccessToken;
}
using var streamReader = new StreamReader(httpResponse2.GetResponseStream());
var result = streamReader.ReadToEnd();
var test = JsonConvert.DeserializeObject<dynamic>(result);
authToken = test!.AccessToken;
}

var url = Program.publicUrl + $"/Shows/{seriesId}/Episodes?api_key={authToken}";
Expand All @@ -84,17 +82,21 @@ public string GetM3U(string seriesId, string? authToken = null, string? username
var test = JsonConvert.DeserializeObject<dynamic>(result);


returnstring += $"\n#PLAYLIST:{test.Items[0].SeriesName}";
returnstring += $"\n#PLAYLIST:{test!.Items[0].SeriesName}";

foreach (var test2 in test.Items)
{
if (test2.IndexNumberEnd != null)
if (test2.IndexNumberEnd != null) // Is it a multi-episode file?
{
returnstring += $"\n#EXTINF:0,{test2.SeriesName}, S{Convert.ToInt32(test2.ParentIndexNumber).ToString().PadLeft(2, '0')}E{Convert.ToInt32(test2.IndexNumber).ToString().PadLeft(2, '0')}-{Convert.ToInt32(test2.IndexNumberEnd).ToString().PadLeft(2, '0')}: {test2.Name}";
returnstring += $"\n#EXTINF:{test2.RunTimeTicks / 10000 / 1000 /* seconds */},{test2.SeriesName}, " +
$"S{Convert.ToInt32(test2.ParentIndexNumber).ToString().PadLeft(2, '0') /* season # */}E{Convert.ToInt32(test2.IndexNumber).ToString().PadLeft(2, '0') /* first episode # */}" +
$"-{Convert.ToInt32(test2.IndexNumberEnd).ToString().PadLeft(2, '0') /* last episode # */}: {test2.Name}";
}
else
{
returnstring += $"\n#EXTINF:0,{test2.SeriesName}, S{Convert.ToInt32(test2.ParentIndexNumber).ToString().PadLeft(2, '0')}E{Convert.ToInt32(test2.IndexNumber).ToString().PadLeft(2, '0')}: {test2.Name}";
returnstring += $"\n#EXTINF:{test2.RunTimeTicks / 10000 / 1000 /* seconds */},{test2.SeriesName}, " +
$"S{Convert.ToInt32(test2.ParentIndexNumber).ToString().PadLeft(2, '0') /* season # */}E{Convert.ToInt32(test2.IndexNumber).ToString().PadLeft(2, '0') /* episode # */}: " +
$"{test2.Name}";
}
returnstring += "\n" + Program.publicUrl + $"/Items/{test2.Id}/Download?api_key={authToken}";
}
Expand Down
Binary file modified Image0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Image1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
149 changes: 149 additions & 0 deletions JSON/Schemas/3897111f-d600-495d-a578-913d19d61704.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
{
"id": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Core schema meta-schema",
"definitions": {
"schemaArray": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#" }
},
"positiveInteger": {
"type": "integer",
"minimum": 0
},
"positiveIntegerDefault0": {
"allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
},
"simpleTypes": {
"enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
},
"stringArray": {
"type": "array",
"items": { "type": "string" },
"minItems": 1,
"uniqueItems": true
}
},
"type": "object",
"properties": {
"id": {
"type": "string"
},
"$schema": {
"type": "string"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"default": {},
"multipleOf": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
},
"maximum": {
"type": "number"
},
"exclusiveMaximum": {
"type": "boolean",
"default": false
},
"minimum": {
"type": "number"
},
"exclusiveMinimum": {
"type": "boolean",
"default": false
},
"maxLength": { "$ref": "#/definitions/positiveInteger" },
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
"pattern": {
"type": "string",
"format": "regex"
},
"additionalItems": {
"anyOf": [
{ "type": "boolean" },
{ "$ref": "#" }
],
"default": {}
},
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/schemaArray" }
],
"default": {}
},
"maxItems": { "$ref": "#/definitions/positiveInteger" },
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
"uniqueItems": {
"type": "boolean",
"default": false
},
"maxProperties": { "$ref": "#/definitions/positiveInteger" },
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
"required": { "$ref": "#/definitions/stringArray" },
"additionalProperties": {
"anyOf": [
{ "type": "boolean" },
{ "$ref": "#" }
],
"default": {}
},
"definitions": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"properties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"patternProperties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"dependencies": {
"type": "object",
"additionalProperties": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/stringArray" }
]
}
},
"enum": {
"type": "array",
"minItems": 1,
"uniqueItems": true
},
"type": {
"anyOf": [
{ "$ref": "#/definitions/simpleTypes" },
{
"type": "array",
"items": { "$ref": "#/definitions/simpleTypes" },
"minItems": 1,
"uniqueItems": true
}
]
},
"format": { "type": "string" },
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" }
},
"dependencies": {
"exclusiveMaximum": [ "maximum" ],
"exclusiveMinimum": [ "minimum" ]
},
"default": {}
}
Loading

0 comments on commit 4a18ceb

Please sign in to comment.