PageRenderTime 76ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 1ms

/Forms/Form1/Form1.Tv.vb

#
Visual Basic | 5202 lines | 4859 code | 206 blank | 137 comment | 11 complexity | 106a7c2f120c9004f75190cd6156e3c1 MD5 | raw file
Possible License(s): GPL-2.0

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

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