PageRenderTime 103ms CodeModel.GetById 30ms app.highlight 56ms RepoModel.GetById 1ms app.codeStats 2ms

/Forms/Form1/Form1.Tv.vb

#
Visual Basic | 5202 lines | 4859 code | 206 blank | 137 comment | 11 complexity | 106a7c2f120c9004f75190cd6156e3c1 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1Imports System.Net
   2Imports System.IO
   3Imports System.Text.RegularExpressions
   4Imports System.Text
   5Imports Media_Companion.WorkingWithNfoFiles
   6Imports System.Xml
   7Imports Media_Companion
   8Imports Media_Companion.Pref
   9Imports System.Linq
  10
  11Partial Public Class Form1
  12    Dim newEpisodeList As New List(Of TvEpisode)
  13    Public languageList As New List(Of Tvdb.Language)
  14    Dim listOfShows As New List(Of str_PossibleShowList)
  15
  16    Dim tvdbposterlist As New List(Of TvBanners)
  17    Dim imdbposterlist As New List(Of TvBanners)
  18    Dim tvdbmode As Boolean = False
  19    Dim usedlist As New List(Of TvBanners)
  20
  21    Dim tvobjects As New List(Of String)
  22
  23#Region "Tv Treeview Routines"
  24    Public Sub tv_ViewReset()
  25        btn_SaveTvShowOrEpisode.Enabled = True
  26        Tv_TreeViewContext_RefreshShow.Enabled = False
  27        Tv_TreeViewContext_RefreshShow.Visible = False
  28        Tv_TreeViewContext_ShowMissEps.Enabled = False
  29        Tv_TreeViewContext_ShowMissEps.Visible = False
  30        Tv_TreeViewContext_DispByAiredDate.Enabled = False
  31        Tv_TreeViewContext_DispByAiredDate.Visible = False
  32        Tv_TreeViewContext_SearchNewEp.Enabled = False
  33        Tv_TreeViewContext_SearchNewEp.Visible = False
  34        Tv_TreeViewContext_FindMissArt.Enabled = False
  35        Tv_TreeViewContext_FindMissArt.Visible = False
  36
  37        Tv_TreeViewContext_ViewNfo.Enabled = False
  38        ExpandSelectedShowToolStripMenuItem.Enabled = False
  39        CollapseSelectedShowToolStripMenuItem.Enabled = False
  40        ExpandAllToolStripMenuItem.Enabled = False
  41        CollapseAllToolStripMenuItem.Enabled = False
  42        Tv_TreeViewContext_ReloadFromCache.Enabled = False
  43        Tv_TreeViewContext_OpenFolder.Enabled = False
  44
  45        tb_ShPremiered.Text = ""
  46        tb_ShGenre.Text = ""
  47        tb_ShTvdbId.Text = ""
  48        tb_ShImdbId.Text = ""
  49        tb_ShRating.Text = ""
  50        tb_ShVotes.Text = ""
  51        tb_ShCert.Text = ""
  52        tb_ShRunTime.Text = ""
  53        tb_ShStudio.Text = ""
  54        cbTvActorRole.Items.Clear()
  55        cbTvActorRole.Text = ""
  56
  57        cbTvActor.Items.Clear()
  58        cbTvActor.Text = ""
  59        PictureBox6.Image = Nothing
  60
  61        tvdbposterlist.Clear()
  62        PictureBox6.Image = Nothing
  63        tv_PictureBoxLeft.Image = Nothing
  64        tv_PictureBoxRight.Image = Nothing
  65        tv_PictureBoxBottom.Image = Nothing
  66        tb_ShPremiered.Text = ""
  67        tb_ShGenre.Text = ""
  68        tb_ShTvdbId.Text = ""
  69        tb_ShImdbId.Text = ""
  70        tb_ShRating.Text = ""
  71        tb_ShVotes.Text = ""
  72        tb_ShCert.Text = ""
  73        tb_ShRunTime.Text = ""
  74        tb_ShStudio.Text = ""
  75        cbTvActorRole.Items.Clear()
  76        cbTvActorRole.Text = ""
  77        tb_ShPlot.Text = ""
  78        cbTvActor.Items.Clear()
  79        cbTvActor.Text = ""
  80
  81        tb_Sh_Ep_Title.Text = ""
  82        tb_ShPremiered.Text = ""
  83        tb_ShGenre.Text = ""
  84        tb_ShTvdbId.Text = ""
  85        tb_ShImdbId.Text = ""
  86        tb_ShRating.Text = ""
  87        tb_ShVotes.Text = ""
  88        tb_ShCert.Text = ""
  89        tb_ShRunTime.Text = ""
  90        tb_ShStudio.Text = ""
  91        cbTvActorRole.Items.Clear()
  92        cbTvActorRole.Text = ""
  93        tb_ShPlot.Text = ""
  94        cbTvActor.Items.Clear()
  95        cbTvActor.Text = ""
  96
  97        cbTvActor.Items.Clear()
  98        cbTvActor.Text = ""
  99        For i = Panel13.Controls.Count - 1 To 0 Step -1
 100            Panel13.Controls.RemoveAt(i)
 101        Next
 102    End Sub
 103
 104    Private Sub TvTreeview_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TvTreeview.AfterSelect
 105        TvTreeview_AfterSelect_Do() 'moved this to seperate sub so we can also call this from other locations.
 106    End Sub
 107
 108    Private Sub TvTreeview_AfterSelect_Do()
 109        Try
 110            'chooses which sub is run to load the relavent tv data to the screen
 111            'note: context menu items are set during TvTreeView_MouseUp event because we only need to update if right click is done which we check in the mouseup sub
 112            'mouseup sub selects the node underneath the mouse & then this runs since its an event 'AfterSelect'
 113
 114            If TvTreeview.SelectedNode Is Nothing Then Exit Sub
 115            If TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvShow Then
 116                tv_ShowLoad(TvTreeview.SelectedNode.Tag)
 117            ElseIf TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvSeason Then
 118                tv_SeasonSelected(TvTreeview.SelectedNode.Tag)
 119            ElseIf TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvEpisode Then
 120                tv_EpisodeSelected(TvTreeview.SelectedNode.Tag)
 121            Else
 122                MsgBox("None")
 123            End If
 124
 125            'tv_SplitContainerAutoPosition() 'auto set container splits....after we have loaded data & pictures....
 126        Catch ex As Exception
 127            ExceptionHandler.LogError(ex)
 128        End Try
 129    End Sub
 130
 131    Private Sub TvTreeview_DragDrop(sender As Object, e As DragEventArgs) Handles TvTreeview.DragDrop
 132        Dim files() As String
 133        files = e.Data.GetData(DataFormats.FileDrop)
 134        For f = 0 To UBound(files)
 135            If IO.Directory.Exists(files(f)) Then
 136                If files(f).ToLower.Contains(".actors") Or files(f).ToLower.Contains("season") Then Continue For
 137                For each fol In Pref.tvRootFolders
 138                    If fol.rpath = files(f) Then Continue For
 139                    If files(f).Contains(fol.rpath) AndAlso Not fol.selected Then
 140                        Dim msg As String = "The series dropped is in a root folder that has been unselected"
 141                        msg &= "To avoid catastrophic failure, please re-select"
 142                        msg &= "root folder: " & fol.rpath 
 143                        msg &= "and attempt again"
 144                        MsgBox (msg)
 145                        Continue For
 146                    End If
 147                Next
 148                'If Pref.tvRootFolders.Contains(files(f)) Then Continue For
 149                Dim di As New IO.DirectoryInfo(files(f))
 150                If Pref.tvFolders.Contains(files(f)) Then Continue For
 151                Dim skip As Boolean = False
 152                For Each item In droppedItems
 153                    If item = files(f) Then
 154                        skip = True
 155                        Exit For
 156                    End If
 157                Next
 158                If Not skip Then droppedItems.Add(files(f))
 159            End If
 160        Next
 161        If droppedItems.Count < 1 Then Exit Sub
 162        Dim droppedmsg As String = "You have dropped the following folders onto TV," &vbCrLf & "Are you sure you wish to add these as TvShows?" & vbCrLf
 163        For Each item In droppedItems
 164            droppedmsg &= item & vbcrlf
 165        Next
 166        Dim x = MsgBox(droppedmsg, MsgBoxStyle.YesNo)
 167        If x = MsgBoxResult.No Then 
 168            droppedItems.Clear()
 169            Exit Sub
 170        End If
 171        For Each item In droppedItems
 172            Pref.tvFolders.add(item)
 173            newTvFolders.Add(item)
 174        Next
 175        droppedItems.Clear()
 176        Pref.ConfigSave()
 177        tv_ShowScrape()
 178    End Sub
 179
 180    Private Sub TvTreeview_DragEnter(sender As Object, e As DragEventArgs) Handles TvTreeview.DragEnter
 181        Try
 182            e.Effect = DragDropEffects.Copy
 183        Catch ex As Exception
 184            ExceptionHandler.LogError(ex)
 185        End Try
 186    End Sub
 187
 188    Private Sub TvTreeviewRebuild()
 189        TvTreeview.BeginUpdate()
 190        Try
 191            Dim shcount As Integer = 0
 192            Dim epcount As Integer = 0
 193            TvTreeview.Nodes.Clear()              'clear the treeview of old data
 194            ''Dirty work around until TvShows is repalced with TvCache.Shows universally
 195            For Each TvShow As Media_Companion.TvShow In Cache.TvCache.Shows
 196                If Not String.IsNullOrEmpty(TvShow.Hidden.Value) AndAlso TvShow.Hidden.Value = True Then Continue For
 197                'TvShow.UpdateTreenode()
 198                shcount += 1
 199                epcount += TvShow.Episodes.Count
 200                TvTreeview.Nodes.Add(TvShow.ShowNode)
 201                TvShow.UpdateTreenode()
 202            Next
 203
 204            If rbTvListAll.Checked Then TvTreeview.BackColor = Color.white
 205            If rbTvListEnded.Checked Then TvTreeview.BackColor = Color.lightpink
 206            If rbTvListContinuing.Checked Then TvTreeview.BackColor = Color.LightSeaGreen
 207            If rbTvListUnKnown.Checked Then TvTreeview.BackColor = Color.LightYellow
 208
 209            TextBox_TotTVShowCount.Text = shcount.ToString     'Cache.TvCache.Shows.Count
 210            TextBox_TotEpisodeCount.Text = epcount.ToString    'Cache.TvCache.Episodes.Count
 211            TvTreeview.Sort()
 212        Finally
 213            TvTreeview.EndUpdate()
 214        End Try
 215    End Sub
 216
 217    Private Sub Tv_TreeViewContextMenuItemsEnable()        'enable/disable right click context menu items depending on if its show/season/episode
 218        '                                                  'called from tv_treeview mouseup event where we check for a right click
 219        If TvTreeview.SelectedNode Is Nothing Then Return
 220        Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)  'set WORKINGTVSHOW to show obj irrelavent if we have selected show/season/episode
 221        Dim showtitle As String = WorkingTvShow.Title.Value       'set our show title
 222
 223
 224
 225        'now we set the items that have variable text in the context menu using the 'show' text set above
 226        Tv_TreeViewContext_ShowTitle.BackColor = Color.Honeydew                'SK - same color as the refresh tv show splash - comments required to see if it works or not....
 227        
 228        If TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvShow Then
 229            Tv_TreeViewContext_ShowTitle.Text = "'" & showtitle & "'"
 230            Tv_TreeViewContext_ShowTitle.Font = New Font("Arial", 10, FontStyle.Bold)
 231            Tv_TreeViewContext_Play_Episode.Enabled = False
 232            Tv_TreeViewContext_ViewNfo.Text = "View TVShow .nfo"
 233            Tv_TreeViewContext_RescrapeShowOrEpisode.Text = "Rescrape TVShow"
 234            Tv_TreeViewContext_WatchedShowOrEpisode.Text = "Mark This Show as Watched"
 235            Tv_TreeViewContext_UnWatchedShowOrEpisode.Text = "Mark This Show as UnWatched"
 236
 237            Tv_TreeViewContext_OpenFolder.Enabled = True
 238            Tv_TreeViewContext_ViewNfo.Enabled = True
 239            Tv_TreeViewContext_RescrapeShowOrEpisode.Enabled = True
 240            Tv_TreeViewContext_WatchedShowOrEpisode.Enabled = True
 241            Tv_TreeViewContext_UnWatchedShowOrEpisode.Enabled = True
 242            Tv_TreeViewContext_RescrapeWizard.Enabled = True
 243            Tv_TreeViewContext_FindMissArt.Enabled = True
 244            Tv_TreeViewContext_RefreshShow.Enabled = True
 245            Tv_TreeViewContext_RefreshShow.Visible = True
 246            Tv_TreeViewContext_MissingEpThumbs.Enabled = True
 247            Tv_TreeViewContext_MissingEpThumbs.Visible = True
 248            Tv_TreeViewContext_ReloadFromCache.Enabled = True
 249            Tv_TreeViewContext_RenameEp.Enabled = rbTvListAll.Checked     'Only show if Treeview set to 'List All'
 250            Tv_TreeViewContext_ShowMissEps.Enabled = True
 251            Tv_TreeViewContext_DispByAiredDate.Enabled = True
 252            tsmiTvDelShowNfoArt.Enabled = True
 253            tsmiTvDelShowEpNfoArt.Enabled = True
 254
 255        ElseIf TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvSeason Then
 256            Tv_TreeViewContext_ShowTitle.Text = "'" & showtitle & "' - " & tv_SeasonSelectedCurrently(TvTreeview).SeasonLabel
 257            Tv_TreeViewContext_ShowTitle.Font = New Font("Arial", 10, FontStyle.Bold)
 258            Tv_TreeViewContext_Play_Episode.Enabled = False
 259            Tv_TreeViewContext_ViewNfo.Text = "View Season .nfo"
 260            Tv_TreeViewContext_RescrapeShowOrEpisode.Text = "Rescrape Season"
 261            Tv_TreeViewContext_WatchedShowOrEpisode.Text = "Mark This Season as Watched"
 262            Tv_TreeViewContext_UnWatchedShowOrEpisode.Text = "Mark This Season as UnWatched"
 263
 264            Tv_TreeViewContext_OpenFolder.Enabled = True
 265            Tv_TreeViewContext_ViewNfo.Enabled = False
 266            Tv_TreeViewContext_RescrapeShowOrEpisode.Enabled = False
 267            Tv_TreeViewContext_WatchedShowOrEpisode.Enabled = True
 268            Tv_TreeViewContext_UnWatchedShowOrEpisode.Enabled = True
 269            Tv_TreeViewContext_RescrapeWizard.Enabled = False
 270            Tv_TreeViewContext_FindMissArt.Enabled = False
 271            Tv_TreeViewContext_RefreshShow.Enabled = False
 272            Tv_TreeViewContext_RefreshShow.Visible = False
 273            Tv_TreeViewContext_MissingEpThumbs.Enabled = True
 274            Tv_TreeViewContext_MissingEpThumbs.Visible = True
 275            Tv_TreeViewContext_ReloadFromCache.Enabled = False
 276            Tv_TreeViewContext_RenameEp.Enabled = rbTvListAll.Checked      'Only show if Treeview set to 'List All'
 277            Tv_TreeViewContext_ShowMissEps.Enabled = True
 278            Tv_TreeViewContext_DispByAiredDate.Enabled = True
 279            tsmiTvDelShowNfoArt.Enabled = False
 280            tsmiTvDelShowEpNfoArt.Enabled = False
 281
 282        ElseIf TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvEpisode Then
 283            Tv_TreeViewContext_ShowTitle.Text = "'" & showtitle & "' - S" & Utilities.PadNumber(ep_SelectedCurrently(TvTreeview).Season.Value, 2) & "E" & Utilities.PadNumber(ep_SelectedCurrently(TvTreeview).Episode.Value, 2) & " '" & ep_SelectedCurrently(TvTreeview).Title.Value & "'"
 284            Tv_TreeViewContext_ShowTitle.Font = New Font("Arial", 10, FontStyle.Bold)
 285            Tv_TreeViewContext_Play_Episode.Enabled = Not DirectCast(TvTreeview.SelectedNode.Tag, Media_Companion.TvEpisode).Ismissing
 286            Tv_TreeViewContext_ViewNfo.Text = "View Episode .nfo"
 287            Tv_TreeViewContext_RescrapeShowOrEpisode.Text = "Rescrape Episode"
 288            Tv_TreeViewContext_WatchedShowOrEpisode.Text = "Mark Episode as Watched"
 289            Tv_TreeViewContext_UnWatchedShowOrEpisode.Text = "Mark Episode as UnWatched"
 290
 291            Tv_TreeViewContext_OpenFolder.Enabled = True
 292            Tv_TreeViewContext_ViewNfo.Enabled = True
 293            Tv_TreeViewContext_RescrapeShowOrEpisode.Enabled = Not DirectCast(TvTreeview.SelectedNode.Tag, Media_Companion.TvEpisode).Ismissing
 294            Tv_TreeViewContext_WatchedShowOrEpisode.Enabled = True
 295            Tv_TreeViewContext_UnWatchedShowOrEpisode.Enabled = True
 296            Tv_TreeViewContext_RescrapeWizard.Enabled = False
 297            Tv_TreeViewContext_FindMissArt.Enabled = False
 298            Tv_TreeViewContext_RefreshShow.Enabled = False
 299            Tv_TreeViewContext_RefreshShow.Visible = False
 300            Tv_TreeViewContext_MissingEpThumbs.Enabled = False
 301            Tv_TreeViewContext_MissingEpThumbs.Visible = False
 302            Tv_TreeViewContext_ReloadFromCache.Enabled = False
 303            Tv_TreeViewContext_RenameEp.Enabled = Not DirectCast(TvTreeview.SelectedNode.Tag, Media_Companion.TvEpisode).Ismissing
 304            Tv_TreeViewContext_ShowMissEps.Enabled = True
 305            Tv_TreeViewContext_DispByAiredDate.Enabled = True
 306            tsmiTvDelShowNfoArt.Enabled = False
 307            tsmiTvDelShowEpNfoArt.Enabled = False
 308
 309        Else
 310            MsgBox("None")
 311        End If
 312
 313        'these are the four items at the bottom of the menu to control Expand/Colapse the tv_treeview (always shown)
 314        ExpandSelectedShowToolStripMenuItem.Enabled = True
 315        ExpandAllToolStripMenuItem.Enabled = True
 316        CollapseAllToolStripMenuItem.Enabled = True
 317        CollapseSelectedShowToolStripMenuItem.Enabled = True
 318    End Sub
 319
 320#End Region
 321
 322    Sub tv_Rescrape_Show(ByVal WorkingTvShow)
 323        Dim tempint As Integer = 0
 324        Dim tempstring As String = ""
 325        tempint = MessageBox.Show("Rescraping the TV Show will Overwrite all the current details" & vbCrLf & "Do you wish to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
 326        If tempint = DialogResult.No Then
 327            Exit Sub
 328        End If
 329        Dim messbox As frmMessageBox = New frmMessageBox("The Selected TV Show is being Rescraped", "", "Please Wait")
 330        System.Windows.Forms.Cursor.Current = Cursors.WaitCursor
 331        messbox.Show()
 332        messbox.Refresh()
 333        Application.DoEvents()
 334        Dim selectedLang As String = WorkingTvShow.Language.Value
 335        If selectedLang = "" Then selectedLang = "en"
 336
 337        If Pref.tvshow_useXBMC_Scraper = True Then
 338            Dim TVShowNFOContent As String = XBMCScrape_TVShow_General_Info("metadata.tvdb.com", WorkingTvShow.TvdbId.Value, selectedLang, WorkingTvShow.NfoFilePath)
 339            If TVShowNFOContent <> "error" Then CreateMovieNfo(WorkingTvShow.NfoFilePath, TVShowNFOContent)
 340            Dim newshow As TvShow = nfoFunction.tvshow_NfoLoad(WorkingTvShow.NfoFilePath)
 341            newshow.ListActors.Clear()
 342            If Pref.TvdbActorScrape = 0 Or Pref.TvdbActorScrape = 3 Or NewShow.ImdbId.Value = Nothing Then
 343                TvGetActorTvdb(NewShow)
 344            ElseIf (Pref.TvdbActorScrape = 1 Or Pref.TvdbActorScrape = 2) And NewShow.ImdbId.Value <> Nothing Then
 345                TvGetActorImdb(NewShow)
 346            End If
 347            If Pref.tvdbIMDbRating Then
 348                Dim rating As String = ""
 349                Dim votes As String = ""
 350                If ep_getIMDbRating(newshow.ImdbId.Value, rating, votes) Then
 351                    newshow.Rating.Value    = rating
 352                    newshow.Votes.Value     = votes
 353                End If
 354            End If
 355            nfoFunction.tvshow_NfoSave(newshow, True)
 356            Call tv_ShowLoad(WorkingTvShow)
 357        Else
 358            For Each episode In WorkingTvShow.Episodes
 359                If Pref.displayMissingEpisodes AndAlso episode.IsMissing = True Then
 360                    Cache.TvCache.Remove(episode)
 361                Else
 362                    Cache.TvCache.Remove(episode)
 363                End If
 364            Next
 365            Cache.TvCache.Remove(WorkingTvShow)
 366            newTvFolders.Add(WorkingTvShow.FolderPath.Substring(0, WorkingTvShow.FolderPath.LastIndexOf("\")))
 367            Dim args As TvdbArgs = New TvdbArgs(WorkingTvShow.TvdbId.Value, selectedLang)
 368            bckgrnd_tvshowscraper.RunWorkerAsync(args)
 369            While bckgrnd_tvshowscraper.IsBusy
 370                Application.DoEvents()
 371            End While
 372        End If
 373        messbox.Close()
 374        TabControl3.SelectedIndex = 0
 375    End Sub
 376
 377
 378    Private Sub tv_ShowLoad(ByVal Show As Media_Companion.TvShow)
 379        Show.ListActors.Clear()
 380        'Dim ShowTemp As TvShow = nfoFunction.tvshow_NfoLoad(Show.NfoFilePath)
 381        Show.Load()
 382        Show = nfoFunction.tvshow_NfoLoad(Show.NfoFilePath) '.Load()
 383        'Show.UpdateTreenode()
 384        
 385        
 386        'Fix episodeguide tag
 387        Dim lang As String = Show.EpisodeGuideUrl.Value
 388        If String.IsNullOrEmpty(lang) Then 
 389            lang = "en"
 390        Else
 391            lang = lang.Substring((lang.LastIndexOf("/")+1)).Replace(".zip","")
 392        End If
 393        
 394        If Not Show.TvdbId.Value = "" Then
 395        Show.EpisodeGuideUrl.Value = ""
 396            Show.Url.Value = URLs.EpisodeGuide(Show.TvdbId.Value, lang) 'Show.Language.Value)
 397            Show.Url.Node.SetAttributeValue("cache", Show.TvdbId.Value)
 398        End If
 399        'end fix
 400
 401        Dim hg As New IO.DirectoryInfo(Show.FolderPath)
 402        If Not hg.Exists Then
 403            tb_ShPlot.Text = "Unable to find folder: " & Show.FolderPath
 404            tb_Sh_Ep_Title.Text = "Unable to find folder: " & Show.FolderPath
 405        Else
 406            If TabControl3.TabPages(1).Text = "Screenshot" Then
 407                TabControl3.TabPages.RemoveAt(1)
 408            End If
 409
 410            'load tvshow.nfo
 411            ListBox3.Items.Clear()
 412            TextBox26.Text = ""
 413            Dim todo As Boolean = False
 414
 415            If Show.State = Media_Companion.ShowState.Locked Then
 416                btn_TvShState.Text = "Locked"
 417                btn_TvShState.BackColor = Color.Red
 418            ElseIf Show.State = Media_Companion.ShowState.Open Then
 419                btn_TvShState.Text = "Open"
 420                btn_TvShState.BackColor = Color.LawnGreen
 421            ElseIf Show.State = Media_Companion.ShowState.Unverified Then
 422                btn_TvShState.Text = "Un-Verified"
 423                btn_TvShState.BackColor = Color.Yellow
 424            Else
 425                btn_TvShState.Text = "Error"
 426                btn_TvShState.BackColor = Color.Gray
 427            End If
 428            btn_TvShState.Tag = Show
 429
 430            If Show.Status.Value = "Ended" Then
 431                bnt_TvSeriesStatus.Text = "Ended"
 432                bnt_TvSeriesStatus.BackColor = Color.LightPink
 433            ElseIf Show.Status.Value = "Continuing" Then
 434                bnt_TvSeriesStatus.Text = "Continuing"
 435                bnt_TvSeriesStatus.BackColor = Color.LightSeaGreen
 436            Else
 437                bnt_TvSeriesStatus.Text = "Unknown"
 438                bnt_TvSeriesStatus.BackColor = Color.LightYellow
 439            End If
 440            Dim tvpbright As String = Utilities.DefaultTvPosterPath 
 441            Dim tvpbbottom As String = Utilities.DefaultTvBannerPath
 442
 443            If Pref.EdenEnabled AndAlso Not Pref.FrodoEnabled Then
 444                If Pref.postertype = "banner" Then
 445                    If Utilities.IsBanner(Show.FolderPath & "folder.jpg") Then
 446                        tvpbbottom = Show.FolderPath & "folder.jpg"
 447                    Else
 448                        tvpbright = Show.ImagePoster.path
 449                    End If
 450                Else
 451                    tvpbright = Show.ImagePoster.path
 452                End If
 453            End If
 454            If Pref.FrodoEnabled Then
 455                Show.ImagePoster.FileName = "poster.jpg"
 456                Show.ImageBanner.FileName = "banner.jpg"
 457                tvpbbottom = Show.ImageBanner.Path
 458                tvpbright = Show.ImagePoster.path
 459            End If
 460            util_ImageLoad(tv_PictureBoxRight, tvpbright, Utilities.DefaultTvPosterPath)
 461            util_ImageLoad(tv_PictureBoxBottom, tvpbbottom, Utilities.DefaultTvBannerPath)
 462            util_ImageLoad(tv_PictureBoxLeft, Show.ImageFanart.Path, Utilities.DefaultTvFanartPath)
 463
 464            Panel_EpisodeInfo.Visible = False
 465            Panel_EpisodeActors.Visible = False
 466            lbl_sorttitle.Visible = True
 467            TextBox_Sorttitle.Visible = True
 468
 469            tb_Sh_Ep_Title.BackColor = Color.White
 470            If Show.Title.Value <> Nothing Then
 471                tb_Sh_Ep_Title.Text = Show.Title.Value
 472
 473            End If
 474
 475            ' changed indication of an issue, setting the title means that the title is saved to the nfo if the user exits. Yellow is the same colour as the unverified Button
 476            If Show.State = ShowState.Unverified Then tb_Sh_Ep_Title.BackColor = Color.Yellow
 477            If Show.State = ShowState.Error Then tb_Sh_Ep_Title.BackColor = Color.Red
 478
 479            tb_ShPremiered.Text = Utilities.ReplaceNothing(Show.Premiered.Value)
 480            tb_ShGenre.Text = Utilities.ReplaceNothing(Show.Genre.Value)
 481            tb_ShTvdbId.Text = Utilities.ReplaceNothing(Show.TvdbId.Value)
 482            tb_ShImdbId.Text = Utilities.ReplaceNothing(Show.ImdbId.Value)
 483            tb_ShRating.Text = Utilities.ReplaceNothing(Show.Rating.Value)
 484            tb_ShVotes.Text = Utilities.ReplaceNothing(Show.Votes.Value)
 485            tb_ShCert.Text = Utilities.ReplaceNothing(Show.Mpaa.Value)
 486            tb_ShRunTime.Text = Utilities.ReplaceNothing(Show.Runtime.Value)
 487            tb_ShStudio.Text = Utilities.ReplaceNothing(Show.Studio.Value)
 488            tb_ShPlot.Text = Utilities.ReplaceNothing(Show.Plot.Value)
 489            TextBox_Sorttitle.Text = Utilities.ReplaceNothing(If(String.IsNullOrEmpty(Show.SortTitle.Value ), Show.Title.Value, Show.SortTitle.Value))
 490
 491            If String.IsNullOrEmpty(Show.SortOrder.Value) Then Show.SortOrder.Value = Pref.sortorder
 492            If Show.SortOrder.Value = "dvd" Then
 493                btn_TvShSortOrder.Text = "DVD"
 494            ElseIf Show.SortOrder.Value = "default" Then
 495                btn_TvShSortOrder.Text = "Default"
 496            End If
 497            '0	-	all from tvdb
 498            '1	-	all from imdb
 499            '2	-	tv imdb, eps tvdb
 500            '3	-	tv TVDB, eps IMDB
 501
 502            If String.IsNullOrEmpty(Show.EpisodeActorSource.Value) Then
 503                If Pref.TvdbActorScrape = "0" Or Pref.TvdbActorScrape = "2" Then
 504                    Show.EpisodeActorSource.Value = "tvdb"
 505                Else
 506                    Show.EpisodeActorSource.Value = "imdb"
 507                End If
 508            End If
 509
 510            Button46.Text = Show.EpisodeActorSource.Value.ToUpper
 511            If String.IsNullOrEmpty(Show.TvShowActorSource.Value) Then
 512                If Pref.TvdbActorScrape = "0" Or Pref.TvdbActorScrape = "3" Then
 513                    Show.TvShowActorSource.Value = "tvdb"
 514                Else
 515                    Show.TvShowActorSource.Value = "imdb"
 516                End If
 517            End If
 518
 519            TvPanel7Update(Show.FolderPath)
 520            Button45.Text = Show.TvShowActorSource.Value.ToUpper
 521            Call tv_ActorsLoad(Show.ListActors)
 522            'Show.UpdateTreenode()
 523        End If
 524        Panel_EpisodeInfo.Visible = False
 525        Panel_EpisodeActors.Visible = False
 526    End Sub
 527
 528    Private Sub tb_ShGenre_MouseDown(sender As Object, e As MouseEventArgs) Handles tb_ShGenre.MouseDown
 529        If e.Button = Windows.Forms.MouseButtons.Right Then
 530            Try
 531                Dim thisshow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
 532                Dim item() As String = thisshow.Genre.Value.Split("/")
 533                Dim genre As String = ""
 534                Dim listof As New List(Of str_genre)
 535                listof.Clear()
 536                For Each i In item
 537                    Dim g As str_genre
 538                    g.genre = i.Trim
 539                    g.count = 1
 540                    listof.Add(g)
 541                Next
 542                Dim frm As New frmGenreSelect 
 543                frm.multicount = 1
 544                frm.SelectedGenres = listof
 545                frm.Init()
 546                If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then
 547                    listof.Clear()
 548                    listof.AddRange(frm.SelectedGenres)
 549                    For each g In listof
 550                        If g.count = 0 Then Continue For
 551                        If genre = "" Then
 552                            genre = g.genre
 553                        Else
 554                            genre += " / " & g.genre
 555                        End If
 556                    Next
 557                    thisshow.Genre.Value = genre
 558                    tb_ShGenre.Text = genre
 559                    nfoFunction.tvshow_NfoSave(thisshow, True) 'thisshow.Save()
 560                End If
 561            Catch
 562            End Try
 563        End If
 564    End Sub
 565
 566    Public Sub tv_ActorsLoad(ByVal listActors As Media_Companion.ActorList)
 567        cbTvActor.Items.Clear()
 568        cbTvActorRole.Items.Clear()
 569        For Each actor In ListActors
 570            If actor.actorname <> Nothing AndAlso Not cbTvActor.Items.Contains(actor.actorname) Then
 571                cbTvActor.Items.Add(actor.actorname)
 572                Dim role As String = actor.actorrole
 573                If String.IsNullOrEmpty(role) Or role = Nothing Then role = actor.actorname
 574                cbTvActorRole.Items.Add(role)
 575            End If
 576        Next
 577
 578        If cbTvActor.Items.Count = 0 Then
 579            actorflag = true
 580            cbTvActorRole.Items.Add("")
 581            cbTvActorRole.SelectedIndex = 0
 582            Call tv_ActorDisplay(True)
 583        Else
 584            cbTvActor.SelectedIndex = 0
 585            'Call tv_ActorDisplay()
 586        End If
 587    End Sub
 588
 589    Public Sub tv_ActorDisplay(Optional ByVal useDefault As Boolean = False)
 590        Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
 591        If WorkingTvShow Is Nothing Then Exit Sub
 592        Dim imgLocation As String = Utilities.DefaultActorPath
 593        Dim eden As Boolean = Pref.EdenEnabled
 594        Dim frodo As Boolean = Pref.FrodoEnabled
 595        PictureBox6.Image = Nothing
 596        If useDefault Then
 597            imgLocation = Utilities.DefaultActorPath
 598        Else
 599            For Each actor In WorkingTvShow.ListActors
 600                If actor.actorname = cbTvActor.Text Then
 601                    Dim temppath As String = Pref.GetActorPath(WorkingTvShow.NfoFilePath, actor.actorname, actor.ID.Value)
 602                    If IO.File.Exists(temppath) Then
 603                        imgLocation = temppath
 604                    ElseIf (Not Pref.LocalActorImage) AndAlso actor.actorthumb <> Nothing AndAlso (actor.actorthumb.IndexOf("http") <> -1 OrElse IO.File.Exists(actor.actorthumb)) Then
 605                        imgLocation = actor.actorthumb
 606                    End If
 607                    Exit For
 608                End If
 609            Next
 610        End If
 611        Try
 612            util_ImageLoad(PictureBox6, imgLocation, Utilities.DefaultActorPath)
 613            PictureBox6.SizeMode = PictureBoxSizeMode.Zoom
 614        Catch
 615        End Try
 616    End Sub
 617
 618    Public Sub tv_ActorRoleDisplay(Optional ByVal useDefault As Boolean = False)
 619        Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
 620        If WorkingTvShow Is Nothing Then Exit Sub
 621        Dim imgLocation As String = Utilities.DefaultActorPath
 622        Dim eden As Boolean = Pref.EdenEnabled
 623        Dim frodo As Boolean = Pref.FrodoEnabled
 624        PictureBox6.Image = Nothing
 625        If useDefault Then
 626            imgLocation = Utilities.DefaultActorPath
 627        Else
 628            For Each actor In WorkingTvShow.ListActors
 629                If actor.actorrole = cbTvActorRole.Text Then
 630                    Dim temppath As String = Pref.GetActorPath(WorkingTvShow.NfoFilePath, actor.actorname, actor.ID.Value)
 631                    If IO.File.Exists(temppath) Then
 632                        imgLocation = temppath
 633                    ElseIf (Not Pref.LocalActorImage) AndAlso actor.actorthumb <> Nothing AndAlso (actor.actorthumb.IndexOf("http") <> -1 OrElse IO.File.Exists(actor.actorthumb)) Then
 634                        imgLocation = actor.actorthumb
 635                    End If
 636                    Exit For
 637                End If
 638            Next
 639        End If
 640        Try
 641            util_ImageLoad(PictureBox6, imgLocation, Utilities.DefaultActorPath)
 642            PictureBox6.SizeMode = PictureBoxSizeMode.Zoom
 643        Catch
 644        End Try
 645    End Sub
 646
 647    Public Function TvCheckforExtraArt(ByVal Showpath As String) As Boolean
 648        Dim confirmedpresent As Boolean = False
 649        If Directory.Exists(Showpath) Then
 650            If File.Exists(Showpath & "clearart.png") Then tvFanlistbox.Items.Add("ClearArt") : confirmedpresent = True
 651            If File.Exists(Showpath & "logo.png") Then tvFanlistbox.Items.Add("Logo") : confirmedpresent = True
 652            If File.Exists(Showpath & "landscape.jpg") Then tvFanlistbox.Items.Add("Landscape") : confirmedpresent = True
 653            If File.Exists(Showpath & "character.png") Then tvFanlistbox.Items.Add("Character") : confirmedpresent = True
 654        End If
 655        Return confirmedpresent 
 656    End Function
 657
 658    Public Sub TvPanel7Update(ByVal TvShPath As String)
 659        tvFanlistbox.Items.Clear()
 660        Panel_TvShowExtraArtwork.Visible = TvCheckforExtraArt(TvShPath)
 661    End Sub
 662
 663    Private Sub tvFanlistbox_Mouse(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles tvFanlistbox.MouseDown
 664        Dim imagepath As String = Nothing
 665        Dim item As String = Nothing
 666        If e.button = Windows.Forms.MouseButtons.Right Then
 667            Dim index As Integer = tvFanlistbox.IndexFromPoint(New Point(e.X, e.Y))
 668            If index >= 0 Then tvFanlistbox.SelectedItem = tvFanlistbox.Items(index)
 669        End If
 670        If IsNothing(tvFanlistbox.SelectedItem) Then Exit Sub
 671        item = tvFanlistbox.SelectedItem.ToString.ToLower
 672        If Not String.IsNullOrEmpty(item) Then
 673                Dim tmpsh As TvShow = tv_ShowSelectedCurrently(TvTreeview)
 674                imagepath = tmpsh.FolderPath 
 675                Dim suffix As String = If((item = "clearart" or item = "logo" or item = "character"),".png", ".jpg")
 676                imagepath &= item & suffix
 677        End If
 678        If e.Button = Windows.Forms.MouseButtons.Left Then 
 679            pbtvfanarttv.Visible = True
 680            If Not IsNothing(imagepath) Then util_ImageLoad(pbtvfanarttv, imagepath, "")
 681        ElseIf e.button = Windows.Forms.MouseButtons.Right Then
 682            Dim tempint = MessageBox.show("Do you wish to delete this image from" & vbCrLf & "this Tv Show?", "Fanart.Tv Artwork Delete", MessageBoxButtons.YesNoCancel)
 683            If tempint = Windows.Forms.DialogResult.No or tempint = DialogResult.Cancel Then Exit Sub
 684            If tempint = Windows.Forms.DialogResult.Yes Then
 685                Utilities.SafeDeleteFile(imagepath)
 686                TvPanel7Update(tv_ShowSelectedCurrently(TvTreeview).FolderPath)
 687            End If
 688        End If
 689    End Sub
 690
 691    Private Sub tvFanlistbox_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tvFanlistbox.MouseLeave
 692        tvFanlistbox.ClearSelected()
 693        pbtvfanarttv.Image = Nothing
 694        pbtvfanarttv.Visible = False
 695    End Sub
 696
 697    Public Sub tv_SeasonSelected(ByRef SelectedSeason As Media_Companion.TvSeason)
 698        SelectedSeason.ShowObj.ListActors.Clear()
 699        SelectedSeason.ShowObj.Load()
 700        Panel_TvShowExtraArtwork.Visible = False
 701        Dim Show As Media_Companion.TvShow
 702        If SelectedSeason.SeasonNode.Parent.Tag IsNot Nothing Then
 703            Show = SelectedSeason.SeasonNode.Parent.Tag
 704        Else
 705            MsgBox("Show tag not set")
 706            Exit Sub
 707        End If
 708        tb_Sh_Ep_Title.BackColor = Color.White
 709        If Show.Title.Value <> Nothing Then
 710            If SelectedSeason.SeasonNumber = 0 Then
 711                tb_Sh_Ep_Title.Text = Utilities.ReplaceNothing(Show.Title.Value) & " - Specials"
 712            Else
 713                tb_Sh_Ep_Title.Text = Utilities.ReplaceNothing(Show.Title.Value) & " - " & Utilities.ReplaceNothing(SelectedSeason.SeasonNode.Text)
 714            End If
 715        End If
 716        If TabControl3.TabPages(1).Text = "Screenshot" Then
 717            TabControl3.TabPages.RemoveAt(1)
 718        End If
 719
 720        ' changed indication of an issue, setting the title means that the title is saved to the nfo if the user exits. Yellow is the same colour as the unverified Button
 721        If Show.State = ShowState.Unverified Then tb_Sh_Ep_Title.BackColor = Color.Yellow
 722        If Show.State = ShowState.Error Then tb_Sh_Ep_Title.BackColor = Color.Red
 723
 724        tb_ShPremiered.Text = Utilities.ReplaceNothing(Show.Premiered.Value)
 725        tb_ShGenre.Text = Utilities.ReplaceNothing(Show.Genre.Value)
 726        tb_ShTvdbId.Text = Utilities.ReplaceNothing(Show.TvdbId.Value)
 727        tb_ShImdbId.Text = Utilities.ReplaceNothing(Show.ImdbId.Value)
 728        tb_ShRating.Text = Utilities.ReplaceNothing(Show.Rating.Value)
 729        tb_ShVotes.Text = Utilities.ReplaceNothing(Show.Votes.Value)
 730        tb_ShCert.Text = Utilities.ReplaceNothing(Show.Mpaa.Value)
 731        tb_ShRunTime.Text = Utilities.ReplaceNothing(Show.Runtime.Value)
 732        tb_ShStudio.Text = Utilities.ReplaceNothing(Show.Studio.Value)
 733        tb_ShPlot.Text = Utilities.ReplaceNothing(Show.Plot.Value)
 734        Panel_EpisodeInfo.Visible = False
 735        Panel_EpisodeActors.Visible = False
 736        lbl_sorttitle.Visible = True
 737        TextBox_Sorttitle.Visible = True
 738        TextBox_Sorttitle.Text = Utilities.ReplaceNothing(If(String.IsNullOrEmpty(Show.SortTitle.Value ), Show.Title.Value, Show.SortTitle.Value))
 739        ExpandSelectedShowToolStripMenuItem.Enabled = True
 740        ExpandAllToolStripMenuItem.Enabled = True
 741        CollapseAllToolStripMenuItem.Enabled = True
 742        CollapseSelectedShowToolStripMenuItem.Enabled = True
 743        Tv_TreeViewContext_RenameEp.Enabled = True
 744        Tv_TreeViewContext_RenameEp.Visible = True
 745
 746        'MsgBox("Season")
 747        Dim season As String = SelectedSeason.SeasonLabel
 748        Dim trueseason As Integer = SelectedSeason.SeasonNumber
 749        Dim PaddedSeason As String = Utilities.PadNumber(SelectedSeason.SeasonNumber, 2)
 750        Dim tvpbright As String = Utilities.DefaultTvPosterPath 
 751        Dim tvpbbottom As String = Utilities.DefaultTvBannerPath 
 752        If trueseason = -1 Then
 753            If SelectedSeason.Poster.Image IsNot Nothing Then
 754                tvpbright = SelectedSeason.Poster.Path 
 755            Else
 756                If Pref.postertype = "banner" Then
 757                    tvpbright = Show.ImagePoster.Path 
 758                Else
 759                    tvpbbottom = Show.ImageBanner.Path 
 760                End If
 761            End If
 762        ElseIf trueseason = 0 Then          'Specials
 763            If Pref.EdenEnabled AndAlso Not Pref.FrodoEnabled Then
 764                tvpbright = Show.FolderPath & "season-specials.tbn"
 765                If Not File.Exists(tvpbright) Then tvpbright = Show.FolderPath & "folder.jpg"
 766            End If
 767            If Pref.FrodoEnabled Then
 768                tvpbright = Show.FolderPath & "season-specials-poster.jpg"
 769                If Not File.Exists(tvpbright) Then tvpbright = Show.FolderPath & "folder.jpg"
 770                tvpbbottom = Show.FolderPath & "season-specials-banner.jpg"
 771                If Not File.Exists(tvpbbottom) Then tvpbbottom = Show.FolderPath & "banner.jpg"
 772            End If
 773        Else                                'Season01 & up
 774            tvpbright = SelectedSeason.Poster.Path
 775            If Pref.FrodoEnabled Then tvpbbottom = SelectedSeason.Banner.Path
 776        End If
 777
 778        util_ImageLoad(tv_PictureBoxRight, tvpbright, Utilities.DefaultTvPosterPath)
 779        util_ImageLoad(tv_PictureBoxBottom, tvpbbottom, Utilities.DefaultTvBannerPath)
 780
 781        If Show.NfoFilePath <> Nothing Then util_ImageLoad(tv_PictureBoxLeft, Show.FolderPath & "fanart.jpg", Utilities.DefaultTvFanartPath)
 782
 783        Call tv_ActorsLoad(Show.ListActors)
 784        Show.UpdateTreenode()
 785    End Sub
 786
 787    Public Sub tv_EpisodeSelected(ByRef SelectedEpisode As Media_Companion.TvEpisode, Optional ByVal Force As Boolean = False)
 788        If TabControl3.TabPages(1).Text <> "Screenshot" Then
 789            If screenshotTab IsNot Nothing Then
 790                TabControl3.TabPages.Insert(1, screenshotTab)
 791                TabControl3.Refresh()
 792            End If
 793        End If
 794        Panel_EpisodeInfo.Visible = True
 795        Panel_EpisodeActors.Visible = True   'set ep actor panel visible, we'll hide later if no actor's in episode.
 796        cmbxEpActor.Items.Clear()
 797        tbEpRole.Text = ""
 798
 799        Dim Show As TvShow = tv_ShowSelectedCurrently(TvTreeview)
 800        Dim season As Integer = SelectedEpisode.Season.Value
 801        Dim episode As Integer = SelectedEpisode.Episode.Value
 802        Dim SeasonObj As New Media_Companion.TvSeason
 803        If SelectedEpisode.EpisodeNode.Parent IsNot Nothing Then
 804            SeasonObj = SelectedEpisode.EpisodeNode.Parent.Tag
 805            If season = -1 Then season = SeasonObj.SeasonLabel
 806        End If
 807
 808        Call ep_Load(SeasonObj, SelectedEpisode, Force)
 809
 810        lbl_sorttitle.Visible = False
 811        TextBox_Sorttitle.Visible = false
 812        Tv_TreeViewContext_ViewNfo.Enabled = True
 813        ExpandSelectedShowToolStripMenuItem.Enabled = True
 814        ExpandAllToolStripMenuItem.Enabled = True
 815        CollapseAllToolStripMenuItem.Enabled = True
 816        CollapseSelectedShowToolStripMenuItem.Enabled = True
 817        Tv_TreeViewContext_ReloadFromCache.Enabled = True
 818        Tv_TreeViewContext_OpenFolder.Enabled = True
 819
 820        If SelectedEpisode.ListActors.Count < 1 Then    'If episode actors, don't load show's actors. (save some time)
 821            If SeasonObj.ShowObj.ListActors.Count = 0 Then Show.Load()
 822            Call tv_ActorsLoad(Show.ListActors)
 823        End If
 824    End Sub
 825
 826    Private Function TestForMultiepisode(ByVal path As String)
 827        Dim multiepisode As Boolean = False
 828        Try
 829            Dim firstline As String = ""
 830            If IO.File.Exists(path) Then
 831                Dim listText As New List(Of String)
 832                Dim objLine As String = ""
 833                Using objReader As StreamReader = New StreamReader(path)
 834                    Do
 835                        objLine = objReader.ReadLine()
 836                        If objLine.IndexOf("<multiepisodenfo>") <> -1 Then
 837                            multiepisode = True
 838                            Exit Do
 839                        ElseIf objLine.IndexOf("<episodedetails>") <> -1 Then
 840                            multiepisode = False
 841                            Exit Do
 842                        End If
 843                    Loop Until objLine Is Nothing
 844                End Using
 845            End If
 846        Catch
 847        End Try
 848        Return multiepisode
 849    End Function
 850
 851    Private Sub ep_Load(ByRef Season As Media_Companion.TvSeason, ByRef Episode As Media_Companion.TvEpisode, Optional ByVal epupdate As Boolean = False)
 852        Panel_TvShowExtraArtwork.Visible = False
 853
 854        'test if already loaded nfo into treeview, if so, then no need to reload
 855        'If IsNothing(Episode.Plot.Value) OrElse epupdate Then
 856            Episode.ListActors.Clear()
 857            Dim episodelist As New List(Of TvEpisode)
 858            episodelist = WorkingWithNfoFiles.ep_NfoLoad(Episode.NfoFilePath)
 859            'test for multiepisodenfo
 860            If episodelist.Count = 1 Then
 861                Episode.AbsorbTvEpisode(episodelist(0))
 862            Else
 863                For Each Ep In episodelist
 864                    If Ep.Season.Value = Episode.Season.Value AndAlso Ep.Episode.Value = Episode.Episode.Value Then
 865                        Episode.AbsorbTvEpisode(Ep)   'update treenode
 866                        Exit For
 867                    End If
 868                Next
 869            End If
 870        'End If
 871
 872        Dim tempstring As String = ""
 873        lb_EpDetails.Items.Clear()
 874
 875        cmbxEpActor.Items.Clear()
 876        tb_EpFilename.Text = Utilities.ReplaceNothing(IO.Path.GetFileName(Episode.NfoFilePath))
 877        tb_EpPath.Text = Utilities.ReplaceNothing(Episode.FolderPath)
 878        If Not IO.File.Exists(Episode.NfoFilePath) Then
 879            tb_Sh_Ep_Title.Text = "Unable to find episode: " & Episode.NfoFilePath
 880            Panel_EpisodeInfo.Visible = True
 881            Panel_EpisodeActors.Visible = True
 882            cmbxEpActor.Items.Clear()
 883            tbEpRole.Text = ""
 884            Episode.EpisodeNode.BackColor = Color.Red
 885            Exit Sub
 886        Else
 887            Episode.EpisodeNode.BackColor = Color.Transparent   'i.e. back to normal
 888        End If
 889
 890        tb_Sh_Ep_Title.Text ="'" &  Utilities.ReplaceNothing(Episode.Title.Value, "?") & "'"
 891        tb_EpRating.Text = Utilities.ReplaceNothing(Episode.Rating.Value)
 892        tb_EpVotes.Text = Utilities.ReplaceNothing(Episode.Votes.Value)
 893        tb_EpPlot.Text = Utilities.ReplaceNothing(Episode.Plot.Value)
 894        tb_EpDirector.Text = Utilities.ReplaceNothing(Episode.Director.Value)
 895        tb_EpCredits.Text = Utilities.ReplaceNothing(Episode.Credits.Value)
 896        tb_EpAired.Text = Utilities.ReplaceNothing(Episode.Aired.Value)
 897        For f = 0 To cbTvSource.Items.Count - 1
 898            If cbTvSource.Items(f) = Episode.Source.value Then
 899                cbTvSource.SelectedIndex = f
 900                Exit For
 901            End If
 902        Next
 903        If Episode.Season.Value = "0" Then
 904            lbl_EpAirBefore.Visible = True 
 905            lbl_EpAirSeason.Visible = True
 906            lbl_EPAirEpisode.Visible = True
 907            tb_EpAirEpisode.Visible = True
 908            tb_EpAirSeason.Visible = True
 909            tb_EpAirSeason.Text = Episode.DisplaySeason.Value
 910            tb_EpAirEpisode.Text = Episode.DisplayEpisode.Value 
 911        Else
 912            lbl_EpAirBefore.Visible = False
 913            lbl_EpAirSeason.Visible = False
 914            lbl_EPAirEpisode.Visible = False
 915            tb_EpAirEpisode.Visible = False
 916            tb_EpAirSeason.Visible = False
 917            tb_EpAirEpisode.Text = ""
 918            tb_EpAirSeason.Text = ""
 919        End If
 920
 921        util_EpisodeSetWatched(Episode.PlayCount.Value)
 922
 923        Dim epdetails As String = ""
 924        epdetails += "Video: " & Utilities.ReplaceNothing(Episode.Details.StreamDetails.Video.Width.Value, "?") & "x" & Utilities.ReplaceNothing(Episode.Details.StreamDetails.Video.Height.Value, "?")
 925        epdetails += ", (" & Utilities.ReplaceNothing(Episode.Details.StreamDetails.Video.Aspect.Value, "?") & ")"
 926        lb_EpDetails.Items.Add(epdetails)
 927        epdetails = " :- " & Utilities.ReplaceNothing(Episode.Details.StreamDetails.Video.Codec.Value, "?")
 928        epdetails += ", @ " & Utilities.ReplaceNothing(Episode.Details.StreamDetails.Video.Bitrate.Value, "?")
 929        lb_EpDetails.Items.Add(epdetails)
 930            
 931        If Episode.Details.StreamDetails.Audio.Count > 0 Then
 932            epdetails = "Audio: " & Utilities.ReplaceNothing(Episode.Details.StreamDetails.Audio(0).Codec.Value, "?")
 933            lb_EpDetails.Items.Add(epdetails)
 934            epdetails = Utilities.ReplaceNothing(Episode.Details.StreamDetails.Audio(0).Bitrate.Value, "?")
 935            epdetails += ", " & Utilities.ReplaceNothing(Episode.Details.StreamDetails.Audio(0).Channels.Value, "?") & " Ch"
 936            lb_EpDetails.Items.Add(epdetails)
 937        End If
 938
 939        Dim aActor As Boolean = False
 940            For Each actor In Episode.ListActors
 941                If Not String.IsNullOrEmpty(actor.actorname) Then
 942                    cmbxEpActor.Items.Add(Utilities.ReplaceNothing(actor.actorname))
 943                    aActor = True
 944                End If
 945            Next
 946        If aActor Then
 947            cmbxEpActor.SelectedIndex = 0
 948        Else
 949            cmbxEpActor.Items.Clear()
 950            cmbxEpActor.Items.Add("")
 951            cmbxEpActor.SelectedIndex = 0
 952            Panel_EpisodeActors.Visible = False 
 953        End If
 954
 955        If (Episode IsNot Nothing AndAlso Episode.Thumbnail IsNot Nothing) Then
 956            Dim eptvleft As String = Episode.Thumbnail.Path 
 957            If Pref.FrodoEnabled Then eptvleft = Episode.Thumbnail.Path.Replace(".tbn", "-thumb.jpg")
 958            util_ImageLoad(tv_PictureBoxLeft, eptvleft, Utilities.DefaultTvFanartPath)
 959        End If
 960        If (Season IsNot Nothing AndAlso Season.Poster IsNot Nothing) Then
 961            util_ImageLoad(tv_PictureBoxRight, Season.Poster.Path, Utilities.DefaultTvPosterPath)
 962            If Pref.FrodoEnabled Then
 963                util_ImageLoad(tv_PictureBoxBottom, Season.Banner.Path, Utilities.DefaultTvBannerPath)
 964            End If
 965        End If
 966
 967        Dim video_flags = GetEpMediaFlags()
 968        movieGraphicInfo.OverlayInfo(tv_PictureBoxLeft, tb_EpRating.Text, video_flags)
 969        Panel_EpisodeInfo.Visible = True
 970
 971    End Sub
 972
 973    Public Function ep_Get(ByVal tvdbid As String, ByVal sortorder As String, ByRef seasonno As String, ByRef episodeno As String, ByVal language As String, ByVal aired As String)
 974        Dim episodestring As String = ""
 975        Dim episodeurl As String = ""
 976        Dim episodeurl2 As String = ""
 977        Dim xmlfile As String = ""
 978
 979        If language.ToLower.IndexOf(".xml") = -1 Then
 980            language = language & ".xml"
 981        End If
 982        episodeurl2 = "http://thetvdb.com/api/6E82FED600783400/series/" & tvdbid & "/" & sortorder & "/" & seasonno & "/" & episodeno & "/" & language
 983        If aired = Nothing Then
 984            episodeurl = "http://thetvdb.com/api/6E82FED600783400/series/" & tvdbid & "/" & sortorder & "/" & seasonno & "/" & episodeno & "/" & language
 985        Else
 986            episodeurl = String.Format("http://thetvdb.com/api/GetEpisodeByAirDate.php?apikey=6E82FED600783400&seriesid={0}&airdate={1}&language={2}", tvdbid, aired, language)
 987        End If
 988        'First try seriesxml data
 989        'check if present, download if not
 990        Dim gotseriesxml As Boolean = False
 991        Dim url As String = "http://www.thetvdb.com/api/6E82FED600783400/series/" & tvdbid & "/all/" & language
 992        Dim xmlfile2 As String = SeriesXmlPath & tvdbid & ".xml"
 993        Dim SeriesInfo As New Tvdb.ShowData
 994        If Not File.Exists(SeriesXmlPath & tvdbid & ".xml") Then
 995            gotseriesxml = DownloadCache.Savexmltopath(url, SeriesXmlPath, tvdbid & ".xml", True)
 996        Else
 997            'Check series xml isn't older than Five days.  If so, re-download it.
 998            Dim dtCreationDate As DateTime = File.GetLastWriteTime(xmlfile2) 
 999            Dim datenow As DateTime = Date.Now()
1000            Dim dif As Long = DateDiff(DateInterval.Day, dtCreationDate, datenow)
1001            If dif > If(aired <> Nothing, 1, 5) Then
1002                gotseriesxml = DownloadCache.Savexmltopath(url, SeriesXmlPath, tvdbid & ".xml", True)
1003            Else
1004                gotseriesxml = True
1005            End If
1006        End If
1007        
1008        If Not gotseriesxml then
1009            xmlfile = Utilities.DownloadTextFiles(episodeurl)
1010            If xmlfile.Contains("No Results from SP") AndAlso (seasonno <> "-1" And epis

Large files files are truncated, but you can click here to view the full file