Permalink
Browse files

New trakt auth

  • Loading branch information...
hidden4003 committed Apr 4, 2018
1 parent e4f2579 commit a960eaf84bd37b21b3dc0a474c628c7f0d863032
@@ -37,50 +37,49 @@
</StackPanel>

<!-- Trakt PIN-->
<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="1" Margin="0,5,15,0" x:Name="spPINLabel">
<TextBlock Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Trakt_PIN}" VerticalAlignment="Center"></TextBlock>
</StackPanel>

<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="1" x:Name="spPINData">
<TextBox Name="txtTraktPIN" Width="150" Margin="0,5,5,0" VerticalAlignment="Center" Text=""/>
</StackPanel>

<StackPanel Orientation="Horizontal" Grid.Column="2" Grid.Row="1" x:Name="spPINLink">
<usercontrols:HyperLinkStandard VerticalAlignment="Center" DisplayText="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Trakt_GetPIN}" URL="https://trakt.tv/pin/5309" Margin="0,0,0,0"/>
<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="2" Margin="0,5,15,0" x:Name="spDeviceCodeLabel">
<TextBlock Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Trakt_DeviceCode}" VerticalAlignment="Center"></TextBlock>
</StackPanel>

<StackPanel Orientation="Horizontal" Grid.Column="2" Grid.Row="2" Margin="0,5,15,0" x:Name="spValidity">
<TextBlock x:Name="tbValidity" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Trakt_CurrentToken}" VerticalAlignment="Center"></TextBlock>
</StackPanel>

<Button Name="btnTest" Margin="0,8,2,2" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" >
<Button Name="btnTest" Margin="0,8,2,2" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Left" >
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left">
<Image Height="16" Width="16" Source="/Images/16_save.png" Margin="0,0,5,0"/>
<TextBlock VerticalAlignment="Center" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Trakt_Authorize}" Margin="0,0,5,0"/>
<TextBlock VerticalAlignment="Center" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Trakt_GetCode}" Margin="0,0,5,0"/>
</StackPanel>
</Button>

<StackPanel Orientation="Horizontal" Grid.Column="2" Grid.Row="2" Margin="0,5,15,0" x:Name="spValidity">
<TextBlock x:Name="tbValidity" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Trakt_CurrentToken}" VerticalAlignment="Center"></TextBlock>
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="3" Margin="0,5,15,0" x:Name="spUserCode">
<TextBlock x:Name="tbUserCode" Text="" FontWeight="Bold" FontSize="16pt" VerticalAlignment="Center"></TextBlock>
</StackPanel>

<StackPanel Orientation="Horizontal" Grid.Column="2" Grid.Row="3" x:Name="spAuthorizeLink">
<usercontrols:HyperLinkStandard x:Name="ucAuthorizeLink" VerticalAlignment="Center" DisplayText="" URL="" Margin="0,0,0,0"/>
</StackPanel>

<!-- Schedule Updates-->
<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="3" Margin="0,5,15,0" x:Name="spUpdatesLabel">
<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="4" Margin="0,5,15,0" x:Name="spUpdatesLabel">
<TextBlock Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=UpdateFrequency}" VerticalAlignment="Center"></TextBlock>
</StackPanel>

<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="3" Margin="0,5,5,0" x:Name="spUpdatesData">
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="4" Margin="0,5,5,0" x:Name="spUpdatesData">
<ComboBox Grid.Row="0" Name="cboUpdateFrequency" VerticalAlignment="Center"></ComboBox>
</StackPanel>

<!-- Episode Auto Download-->
<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="4" Margin="0,5,15,0" x:Name="spEpisodeLabel">
<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="5" Margin="0,5,15,0" x:Name="spEpisodeLabel">
<TextBlock Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Trakt_AutoEpisodeImages}" VerticalAlignment="Center"></TextBlock>
</StackPanel>

<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="4" VerticalAlignment="Center" Margin="0,5,5,0" x:Name="spEpisodeData">
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="5" VerticalAlignment="Center" Margin="0,5,5,0" x:Name="spEpisodeData">
<CheckBox Name="chkTrakt_EpisodeAutoDownload" IsChecked="{Binding Source={x:Static local:VM_ShokoServer.Instance},Path=Trakt_DownloadEpisodes}" VerticalAlignment="Center"/>
</StackPanel>

<!-- Visit Website -->
<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="5" Margin="0,10,15,0">
<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="6" Margin="0,10,15,0">
<usercontrols:HyperLinkStandard VerticalAlignment="Center" DisplayText="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=VisitWebsite}" URL="http://trakt.tv" Margin="0,0,0,0"/>
</StackPanel>

@@ -59,8 +59,12 @@ void cboUpdateFrequency_SelectionChanged(object sender, SelectionChangedEventArg

void btnTest_Click(object sender, RoutedEventArgs e)
{
VM_ShokoServer.Instance.AuthorizeTraktPIN(txtTraktPIN.Text.Trim());
VM_ShokoServer.Instance.GetServerSettings();
var deviceCode = VM_ShokoServer.Instance.GetTraktDeviceCode();

tbUserCode.Text = deviceCode.UserCode;
ucAuthorizeLink.URL = deviceCode.VerificationUrl;
ucAuthorizeLink.DisplayText = deviceCode.VerificationUrl;

EvaluateVisibility();
}

@@ -69,9 +73,8 @@ private void EvaluateVisibility()
Visibility vis = Visibility.Collapsed;
if (VM_ShokoServer.Instance.Trakt_IsEnabled) vis = Visibility.Visible;

spPINLabel.Visibility = vis;
spPINData.Visibility = vis;
spPINLink.Visibility = vis;
spUserCode.Visibility = vis;
spAuthorizeLink.Visibility = vis;

btnTest.Visibility = vis;
spValidity.Visibility = vis;
@@ -90,7 +90,7 @@ public static VideoInfo ToVideoInfo(this VM_VideoLocal vid, bool forcebegining)
string fname = Path.GetFileNameWithoutExtension(fullname);
if (p.Streams != null)
{
foreach (Models.PlexAndKodi.Stream s in p.Streams.Where(a => a.File != null && a.StreamType == "3"))
foreach (Models.PlexAndKodi.Stream s in p.Streams.Where(a => a.File != null && a.StreamType == 3))
{
string extension = Path.GetExtension(s.File);
string filePath = Path.Combine(Path.GetTempPath(), Path.GetDirectoryName(fullname));
@@ -567,22 +567,17 @@ public void TestAniDBLogin()

}

public void AuthorizeTraktPIN(string pin)
public CL_TraktDeviceCode GetTraktDeviceCode()
{
try
{
SaveServerSettings();

Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(AppSettings.Culture);

string response = ShokoServices.EnterTraktPIN(pin);
MessageBox.Show(response, Shoko.Commons.Properties.Resources.ShokoServer_TraktAuth, MessageBoxButton.OK, MessageBoxImage.Information);

return ShokoServices.GetTraktDeviceCode();
}
catch (Exception ex)
{
Utils.ShowErrorMessage(ex);
}
return new CL_TraktDeviceCode();
}

public void TestMALLogin()

0 comments on commit a960eaf

Please sign in to comment.