 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
BobTom
Joined: 27 Aug 2006 Posts: 15 Location: Virginia
|
Posted: Sun Oct 22, 2006 7:36 pm Post subject: Program for getting TV show and episode info from TV.com |
|
|
Update: The search function is now working again and I have updated the code below so feel free to give it a try!
Version 2.0!! Added Favorites
Added a search option, fixed the summarys and worked out a few other bugs. Enjoy!
A program that helps me get TV Show info from TV.com without navigating through their sometimes slow website.
Please let me know what you think.
| Code: |
IfWinExist, TV Show Episode Guide
{
WinActivate, Episode Guide
return
}
SaveDir = c:\tvcom\
FileCreateDir, %SaveDir%ShowPages\
FileCreateDir, %SaveDir%ShowPics\
IfExist, %A_MyDocuments%\TVEGSettings.ini
IniRead, FavSaveFolder, %A_MyDocuments%\TVEGSettings.ini, Save Folder, Key
Else
FavSaveFolder = C:\
IfNotExist, %SaveDir%ShowPics\DefaultShowPic.jpg
URLDownloadToFile, http://travsphotos.com/DefaultShowPic.jpg, %SaveDir%ShowPics\DefaultShowPic.jpg
SeasonsDropDown =
GettingShowNames = No
GettingShowInfo = No
AllShowsGet = No
EpisodeSumName = `nEpisode Summary:
EpisodeSumSet = No
ShowsListed = No
EpisodesListed = No
FavsListed = No
ContMenuCreated = No
ActivateGui:
ListKeys = Choose:||All Shows|#|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z
Menu, FileMenu, Add, E&xit, GuiClose
Menu, ToolMenu, Add, &Options, OptionsMenu
Menu, HelpMenu, Add, &Tv.com Website, OpenWebsite
Menu, HelpMenu, Add, &About, About
Menu, MyMenuBar, Add, &File, :FileMenu
Menu, MyMenuBar, Add, &Tools, :ToolMenu
Menu, MyMenuBar, Add, &Help, :HelpMenu
Gui, Menu, MyMenuBar
Gui, Add, Text, x326 y10 w40 h20 , Search:
Gui, Add, Edit, x376 y10 w100 h20 vSearchBox,
Gui, Add, Button, x216 y10 w70 h20 vFavButton gFavButton, Favorites
Gui, Add, Text, x16 y10 w80 h20 , Browse Shows:
Gui, Add, DropDownList, x106 y10 w70 h20 R5 vBrowseDDLText gBrowseDDLSelect, %ListKeys%
Gui, Add, Text, x16 y40 w230 h20 vShowsText, Shows:
Gui, Add, ListView, x16 y60 w230 h120 -Hdr -Multi vShowLV gShowLVSelect, ListView
Gui, Add, Text, x266 y40 w90 h20 , Show Summary:
Gui, Add, Edit, x266 y60 w210 h130 vShowSumEdit,
Gui, Add, Text, x16 y190 w50 h20 , Season:
Gui, Add, DropDownList, x76 y190 w100 h20 R5 vSeasonsDDLText gSeasonDDLSelect, %SeasonsDropDown%
Gui, Add, Text, x16 y220 w60 h20 , Episodes:
Gui, Add, ListView, x16 y240 w230 h160 -Multi vEpisodeLV gEpisodeLVSelect, #|Name|Date
Gui, Add, Text, x266 y200 w192 h30 vEpisodeSumTitle, %EpisodeSumName%
Gui, Add, Edit, x266 y230 w210 h170 vEpisodeSumEdit,
Gui, Add, Button, x346 y730 w110 h50 Default gOKButton, OK
Gui, Add, Picture, x16 y410 w460 h80 vShowPicture, %SaveDir%ShowPics\DefaultShowPic.jpg
Gui, Add, Text, x21 y433 w320 h50 -Wrap cwhite BackgroundTrans vShowPicTitle,
Gui, Show, x303 y178 h505 w491 , TV Show Episode Guide
return
GuiContextMenu:
If A_GuiControl <> ShowLV
return
Row# := LV_GetNext(0, "Focused")
LV_GetText(ShowText, Row#)
FavShow := ShowText
; If A_GuiControl <> ShowLV
; return
If ContMenuCreated = Yes
Menu, ContextMenu, Delete
If FavsListed = Yes
Menu, ContextMenu,Add, Remove Favorite, ContextRemoveFavs
Else
Menu, ContextMenu,Add, Add To Favorites, ContextAddFavs
Menu, ContextMenu, Show, %A_GuiX%, %A_GuiY%
ContMenuCreated = Yes
return
OptionsMenu:
Gui, 2:Add, Button, x255 y163 w50 h20 gOptionsExitButton, Exit
Gui, 2:Add, Tab, x6 y10 w300 h150,Favorites
Gui, 2:Tab, Favorites
Gui, 2:Add, Text, x14 y40 w240 h20,Place To Save Favorites:
Gui, 2:Add, Edit, x13 y55 w263 h20 vFavSaveEdit,%FavSaveFolder%TVFavorites.txt
Gui, 2:Add, Button, x280 y55 w20 h20 gFolderSelect,...
Gui, 2:Add, Button, x246 y130 w50 h20 gSaveFolderButton,Save
Gui, 2:Show, x313 y155 h187 w313, Options
return
FolderSelect:
PrevFavSaveFolder := FavSaveFolder
FileSelectFolder, FavSaveFolder, *C:\
If ErrorLevel = 1
FavSaveFolder := PrevFavSaveFolder
StringRight, LastChar, FavSaveFolder, 1
if LastChar <> \
FavSaveFolder = %FavSaveFolder%\
GuiControl, ,FavSaveEdit, %FavSaveFolder%TVFavorites.txt
return
SaveFolderButton:
PrevFavSaveFolderFile = %PrevFavSaveFolder%TVFavorites.txt
FavSaveFolderFile = %FavSaveFolder%TVFavorites.txt
If PrevFavSaveFolderFile <> %FavSaveFolderFile%
{
IfExist, %PrevFavSaveFolderFile%
FileMove, %PrevFavSaveFolderFile%, %FavSaveFolderFile%
Else
{
FileAppend, ,%FavSaveFolderFile%
If ErrorLevel <> 0
MsgBox Error
}
}
IniWrite, %FavSaveFolder%, %A_MyDocuments%\TVEGSettings.ini, Save Folder, Key
return
OptionsExitButton:
GoSub, 2GuiClose
return
OpenWebsite:
Run www.tv.com
return
About:
Gui, 2:Add, Text, Center x16 y10 w290 h180 vAboutWin gAboutWin, All information obtained with this program is from TV.com and therefore copyrights held by TV.com for this information is still in effect.`n`nProgram Created by: Travis Himes`n`nVersion 1.5
Gui, 2:Show, x239 y133 h209 w325, About
Send ^{Home}
return
AboutWin:
GoSub, GuiClose
return
BrowseDDLSelect:
If GettingShowNames = Yes
return
BrowseSearchFavs = Browse
GuiControlGet, BrowseDDLText, ,
Guicontrol, ,ShowPicture, %SaveDir%ShowPics\DefaultShowPic.jpg
If BrowseDDLText = Choose:
return
Else If BrowseDDLText = All Shows
{
GoSub, GetAllShowPages
If IsFileOld = Yes
{
MsgBox, 4, All Shows, This will take a while to download all shows. Are you sure you want to continue?
IfMsgBox Yes
GoSub, GetAllShowPages
IfMsgBox No
return
}
}
Else
{
If BrowseDDLText = #
BrowseDDLText = 9
ShowsLetter := BrowseDDLText
GoSub, ClearControlsforShowList
GoSub, ListShowPages
If IsFileOld = Yes
Gosub, GetShowNames
}
FavsListed = No
return
FavButton:
BrowseSearchFavs = Favs
Gui, ListView, ShowLV
LV_Delete()
ShowsListed = No
ShowNameLine# = 1
GuiControl, +Sort, ShowLV,
Loop, Read, %FavSaveFolder%TVFavorites.txt,
{
Fileline = %A_LoopReadLine%
Fileline# = %A_Index%
If Fileline# = %ShowNameLine#%
{
LV_Add("", Fileline)
ShowNameLine# := ShowNameLine# + 3
}
}
GuiControl, Focus, ShowLV
LV_Modify(1, "Select Focus")
ShowsListed = Yes
GuiControl, -Sort, ShowLV,
FavsListed = Yes
return
ShowLVSelect:
If (GettingShowInfo = "yes" or ShowsListed = "No")
return
If A_GuiEvent = DoubleClick
{
Gui, ListView, ShowLV
Show#ForInfo = %A_EventInfo%
LV_GetText(ShowText, A_EventInfo, 1)
}
GuiControl, ,ShowSumEdit, Please Wait...
GoSub, ClearControls
GoSub, GetSeasons
GuiControl, Focus, SeasonsDDLText
GoSub, FindShowSummary
return
SeasonDDLSelect:
GuiControlGet, SeasonsDDLText, ,
If SeasonsDDLText = Choose:
return
Else
{
GuiControl, -Center,EpisodeSumTitle,
Gui, Font, Norm
If EpisodeSumSet = Yes
{
GuiControl, Font, EpisodeSumTitle
EpisodeSumSet = No
}
GuiControl, ,EpisodeSumTitle, `nEpisode Summary:
GuiControl, ,EpisodeSumEdit,
Gui, ListView, EpisodeLV
LV_Delete()
LV_Add("", "Please Wait...")
LV_ModifyCol()
GoSub, ListEpisodes
GuiControl, Focus, EpisodeLV
}
return
EpisodeLVSelect:
If EpisodesListed = No
return
If A_GuiEvent = DoubleClick
{
Gui, ListView, EpisodeLV
Episode#ForSum = %A_EventInfo%
LV_GetText(EpisodeSumName, A_EventInfo, 2)
}
GuiControl, ,EpisodeSumEdit, Please Wait..
GoSub, FindEpisodeSummary
return
OKButton:
OKbuttonPressed = Yes
GuiControlGet, FocusedCon, FocusV
If FocusedCon = ShowLV
{
If GettingShowInfo = Yes
return
Gui, ListView, ShowLV
Show#ForInfo := LV_GetNext(0, "Focused")
LV_GetText(ShowText, Show#ForInfo)
GoSub, ShowLVSelect
return
}
Else If FocusedCon = EpisodeLV
{
Gui, ListView, EpisodeLV
LVRowSelection := LV_GetNext(0, "Focused")
LV_GetText(EpisodeSumName, LVRowSelection, 2)
GoSub, EpisodeLVSelect
}
Else If FocusedCon = Searchbox
{
If GettingShowNames = Yes
return
BrowseSearchFavs = Search
Guicontrol, ,ShowPicture, %SaveDir%ShowPics\DefaultShowPic.jpg
GuiControl, ,ShowSumEdit,
Gui, ListView, ShowLV
LV_Delete()
LV_Add("", "Please Wait...")
GuiControl, Focus, ShowLV
GuiControl, , ShowsText, Shows: Downloading...
GuiControlGet, SearchShow, ,SearchBox
GoSub, ClearControls
GoSub, SearchShows
FavsListed = No
}
Else
return
OKbuttonPressed = No
return
ClearControlsforShowList:
GoSub, ClearControls
GuiControl, ,ShowSumEdit,
GuiControl, -Center,EpisodeSumTitle,
Gui, Font, Norm
If EpisodeSumSet = Yes
{
GuiControl, Font, EpisodeSumTitle
EpisodeSumSet = No
}
GuiControl, ,EpisodeSumTitle, `nEpisode Summary:
EpisodeSumSet = No
Gui, ListView, ShowLV
LV_Delete()
ShowsListed = No
LV_Add("", "Please Wait...")
GuiControl, Focus, ShowLV
GuiControl, , ShowsText, Shows: Downloading...
return
ClearControls:
GuiControl, , ShowPicTitle,
GuiControl, ,SeasonsDDLText, |
Gui, ListView, EpisodeLV
LV_Delete()
EpisodesListed = No
GuiControl, -Center,EpisodeSumTitle,
Gui, Font, Norm
If EpisodeSumSet = Yes
{
GuiControl, Font, EpisodeSumTitle
EpisodeSumSet = No
}
GuiControl, ,EpisodeSumTitle, `nEpisode Summary:
EpisodeSumSet = No
GuiControl, ,EpisodeSumEdit,
return
ListShowPages:
LSP_Link = http://www.tv.com/shows/az.html?era=&g=&l=%ShowsLetter%&tag=browse;%ShowsLetter%
PageListFile = %SaveDir%ShowPages\%ShowsLetter%Pages.txt
If TheLastLSP_Link != %LSP_Link%
{
FileDelete, %PageListFile%
URLDownloadToFile, %LSP_Link% , %PageListFile%
If ErrorLevel != 0
MsgBox, ,Error, Error 50
FileRead, PageList, %PageListFile%
}
PageLoop# = 1
PageSet = 0
Page# =
LookForPages = pagination;
If PageList =
MsgBox , ,Error, Error 51
Loop, Parse, PageList,`n
{
FileLine = %A_LoopField%
FileLine# = %A_Index%
IfInString, FileLine, %LookForPages%
{
Fileline = %FileLine%
IfInString, Fileline, pagination;next
continue
Else
{
StringLen, Page#Len1, Fileline
Page#Len1 := Page#Len1 - 2
StringTrimLeft, Page#, Fileline, %Page#Len1%
If PageLoop# = 1
PageSet = %Page#%
Else If Page# = %PageSet%
{
Pages = %pageloop#%
break
}
PageLoop#++
}
IfInString, Fileline, ...
{
StringGetPos, TotalPage#Left, Fileline, ...
TotalPage#Left := TotalPage#Left + 5
StringGetPos, TotalPage#Right, Fileline, /a>,
TotalPageAmountToTrim := TotalPage#Right - TotalPage#Left
StringMid, TotalPage, Fileline, %TotalPage#Left%, %TotalPageAmountToTrim%
Pages = %TotalPage%
break
}
}
}
TheLastLSP_Link = %LSP_Link%
GoSub, GetShowNames
return
GetShowNames:
IsFileOld = No
GettingShowNames = Yes
GSN_LoopCount = 0
GSN_LoopCountFile = 1
ShowTitleLoop# = 0
IfExist, %SaveDir%%ShowsLetter%ShowNames.txt
{
FileGetTime, FileTime, %SaveDir%%ShowsLetter%ShowNames.txt, M
GoSub, CheckTime
If NowTime = 7
{
FileDelete, %SaveDir%%ShowsLetter%ShowNames.txt
IsFileOld = Yes
return
}
FirstShowFileline# = 1
Loop, Read, %SaveDir%%ShowsLetter%ShowNames.txt,
{
FileLine = %A_LoopReadLine%
FileLine# = %A_Index%
If FileLine# = %FirstShowFileLine#%
{
ShowTitle := FileLine
ShowNameFileline# := FirstShowFileline# + 3
If AllShowsGet = No
LV_Delete()
LV_Add("Select Focus", ShowTitle)
}
Else If FileLine# = %ShowNameFileline#%
{
ShowTitle := FileLine
ShowNameFileline# := ShowNameFileline# + 3
LV_Add("", ShowTitle)
}
}
}
Else
{
Loop, %Pages% {
GSN_Link = http://www.tv.com/shows/az.html?l=%ShowsLetter%&era=&pg_shows=%GSN_LoopCount%&tag=pagination;%GSN_LoopCountFile%
ShowNamesFile = %SaveDir%ShowPages\%ShowsLetter%ShowsPage%GSN_LoopCountFile%.txt
IfNotExist, %ShowNamesFile%
URLDownloadToFile, %GSN_Link%, %ShowNamesFile%
FileRead, ShowList, %ShowNamesFile%
LookForShowTitle = `;title`;
Loop, Parse, ShowList,`n
{
FileLine = %A_LoopField%
FileLine# = %A_Index%
IfInString, FileLine, %LookForShowTitle%
{
Shw_FileLine = %FileLine%
;Get Show Names
StringGetPos, ShowTitleLeftPos, Shw_FileLine, f-bold">
ShowTitleLeftPos := ShowTitleLeftPos + 9
StringGetPos, ShowTitleRightPos, Shw_FileLine, /a>
ShowTitleAmountToTrim := ShowTitleRightPos - ShowTitleLeftPos
StringMid, ShowTitle, Shw_FileLine, %ShowTitleLeftPos%, %ShowTitleAmountToTrim%
;Get Show Link
StringGetPos, ShowLinkLeftPos, Shw_FileLine, tt
StringGetPos, ShowLinkRightPos, Shw_FileLine, " cla
ShowLinkRightPos := ShowLinkRightPos + 1
ShowLinkAmountToTrim := ShowLinkRightPos - ShowLinkLeftPos
StringMid, ShowLink, Shw_FileLine, %ShowLinkLeftPos%, %ShowLinkAmountToTrim%
;Add To Gui
Gui, Listview, ShowLV
If ShowTitleLoop# = 0
{
If AllShowsGet = No
LV_Delete()
LV_Add("Select Focus", ShowTitle)
}
Else
LV_Add("", ShowTitle)
ShowTitleLoop#++
AllShowsLoop#++
;%ShowTitleLoop#%`n
FileAppend, %ShowTitle%`n%ShowLink%`n`n, %SaveDir%%ShowsLetter%ShowNamesTemp.txt
If AllShowsGet = Yes
;%AllShowsLoop#%`n
FileAppend, %ShowTitle%`n%ShowLink%`n`n, %SaveDir%AllShowNamesTemp.txt
}
}
GSN_LoopCount++
GSN_LoopCountFile++
}
}
If AllShowsGet = No
GuiControl, , ShowsText, Shows: Finished Downloading
FileMove, %SaveDir%%ShowsLetter%ShowNamesTemp.txt, %SaveDir%%ShowsLetter%ShowNames.txt
GettingShowNames = No
ShowsListed = Yes
return
GetSeasons:
ShowName := ShowText
GettingShowInfo = Yes
ShowNameChanged = No
If BrowseSearchFavs = Search
ShowFile = %SaveDir%%SearchShow%SearchResults.txt
Else If BrowseSearchFavs = Browse
ShowFile = %SaveDir%%BrowseDDLText%ShowNames.txt
Else If BrowseSearchFavs = Favs
ShowFile = %FavSaveFolder%TVFavorites.txt
ShowLinkLine# = 0
ShowLink =
Loop, Read, %ShowFile%,
{
FileLine = %A_LoopReadLine%
FileLine# = %A_Index%
If BrowseSearchFavs = Favs
{
If FileLine = %ShowName%
ShowLinkLine# := FileLine# + 1
}
Else
{
If FileLine = %ShowName%
ShowLinkLine# := FileLine# + 1
}
If FileLine# = %ShowLinkLine#%
ShowLink := FileLine
}
; MsgBox %showname%
; MsgBox %showLink%
IfInString, ShowName, /
{
StringReplace, ShowName, ShowName, /, -
ShowNameChanged = Yes
}
StringGetPos, ShowEpiLinkLeft, ShowLink, summary
StringLen, ShowLinkLen, ShowLink
ShowLinkAmountToTrim := ShowLinkLen - ShowEpiLinkLeft
StringTrimRight, ShowLink, ShowLink, %ShowLinkAmountToTrim%
ShowEpiLink = %ShowLink%episode_listings.html
ShowNameFile = %SaveDir%%ShowName%.txt
URLDownloadToFile, %ShowEpiLink%, %ShowNameFile%
FileRead, ShowInfo, %ShowNameFile%
StringLen, ShowName#Chars, ShowName
SeasonsDropDown = Choose:||
NumofSeasonsLoop = 0
LookFor#SeasonsFound = No
Season1Found = No
LookFor#Seasons = season_dropdown
LookForPicture = content-head
Loop, Parse, ShowInfo,`n
{
Fileline = %A_LoopField%
IfInString, Fileline, %LookForPicture%
{
IfInString, Fileline, background-image:url
{
IfNotExist, %SaveDir%ShowPics\%ShowName%Pic.jpg
{
StringGetPos, PicLinkLeftPos, FileLine, tt
StringGetPos, PicLinkRightPos, FileLine, );"
PicLinkRightPos := PicLinkRightPos + 1
PicLinkAmountToTrim := PicLinkRightPos - PicLinkLeftPos
StringMid, PicLink, FileLine, %PicLinkLeftPos%, %PicLinkAmountToTrim%
URLDownloadToFile, %PicLink%, %SaveDir%ShowPics\%ShowName%Pic.jpg
GoSub, DisplayPic
}
Else
GoSub, DisplayPic
}
}
IfInString, FileLine, %LookFor#Seasons%
{
LookFor#SeasonsFound = Yes
IfInString, FileLine, All Seasons
continue
NumofSeasonsLoop++
SeasonsDropDown = %SeasonsDropDown%%NumofSeasonsLoop%|
}
IfInString, FileLine, Season 1
Season1Found = Yes
}
If (LookFor#SeasonsFound = "No" and Season1Found = "Yes")
SeasonsDropDown = %SeasonsDropDown%1|
GuiControl, ,SeasonsDDLText, %SeasonsDropDown%
return
DisplayPic:
FileGetSize, ShowPicFileSize, %SaveDir%ShowPics\%ShowName%Pic.jpg, K
If ShowPicFileSize > 1
ShowPicFile = %SaveDir%ShowPics\%ShowName%Pic.jpg
Else
{
FileDelete, %SaveDir%ShowPics\%ShowName%Pic.jpg
ShowPicFile = %SaveDir%ShowPics\DefaultShowPic.jpg
}
If ShowName#Chars > 20
{
GuiControl, Move, ShowPicTitle, x21 y439 w500 h50
Gui, Font,Bold s12 cWhite
}
Else If ShowName#Chars < 14
{
GuiControl, Move, ShowPicTitle, x21 y433 w320 h50
Gui, Font,Bold s20 cWhite
}
Else
{
GuiControl, Move, ShowPicTitle, x21 y433 w410 h50
Gui, Font,Bold s16 cWhite
}
If ShowNameChanged = Yes
StringReplace, ShowName, ShowName, -, /
GuiControl, Font ,ShowPicTitle,
GuiControl, , ShowPicTitle, %ShowName%
GuiControl, Move, ShowPicture, x16 y410 w460 h80
GuiControl, , ShowPicture, %ShowPicFile%
return
FindShowSummary:
ShowSummaryFound = No
ShowSum =
ShowSumDownloadError = No
IfInString, ShowName, /
StringReplace, ShowName, ShowName, /, -
ShowSumLink = %ShowLink%summary.html?full_summary=1
ShowSumFile = %SaveDir%%ShowName%-FullSummary.txt
IfNotExist, %SaveDir%%ShowName%-FullSummary.txt
{
URLDownloadToFile, %ShowSumLink%, %ShowSumFile%
If ErrorLevel <> 0
ShowSumDownloadError = Yes
}
FileRead, ShowSumPage, %ShowSumFile%
ShowSummaryStartFound = No
ShowSummaryFound = No
LookForFullSum = <div class="mt-10">
Loop, Parse, ShowSumPage,`n
{
FileLine = %A_LoopField%
IfInString, FileLine, %LookForFullSum%
ShowSummaryStartFound = Yes
If ShowSummaryStartFound = Yes
{
If FileLine = </div>
{
StringTrimRight, ShowSum, ShowSum, 2
break
}
StringLen, ShowSumCheckLen, FileLine
ShowSumCheckAmountToTrim := ShowSumCheckLen - 3
StringTrimRight, ShowSumCheckLine, FileLine, %ShowSumCheckAmountToTrim%
If ShowSumCheckLine =
continue
Else IfInString, ShowSumCheckLine, <
{
If (ShowSumCheckLine = "<b>" or ShowSumCheckLine = "<i>" or ShowSumCheckLine = "<I>")
GoSub, GetShowSummary
Else
Continue
}
Else
GoSub, GetShowSummary
}
}
If ShowSumDownloadError = Yes
GuiControl, , ShowSumEdit, The Summary could not be downloaded for this show.
else If ShowSummaryFound = No
GuiControl, ,ShowSumEdit, No Summary was found for this show.
else
GuiControl, , ShowSumEdit, %ShowSum%
GettingShowInfo = No
return
GetShowSummary:
Loop {
IfInString, FileLine, <
{
StringGetPos, HTMLTagLeftPos, FileLine, <
StringGetPos, HTMLTagRightPos, FileLine, >
HTMLTagLeftPos := HTMLTagLeftPos + 1
HTMLTagAmountToTrim := HTMLTagRightPos - HTMLTagLeftPos + 2
StringMid, HTMLTag, FileLine, %HTMLTagLeftPos%, %HTMLTagAmountToTrim%
StringReplace, FileLine, FileLine, %HTMLTag%,
}
Else
{
ShowSum = %ShowSum%%FileLine%`n`n
break
}
}
ShowSummaryFound = Yes
return
ListEpisodes:
FileDelete, %SaveDir%EpisodeNames.txt
ListEpisodeLink = %ShowEpiLink%?season=%SeasonsDDLText%
ShowEpisodeListFile = %SaveDir%%ShowText%%SeasonsDDLText%.txt
URLDownloadToFile, %ListEpisodeLink%, %ShowEpisodeListFile%
FileRead, EpisodeList, %ShowEpisodeListFile%
;FileDelete, %ShowEpisodeListFile%
EpiDateLine# =
EpiLoop# = 0
PleaseWaitLoop = 0
IsEpisodes = no
LookForSeason = bold">Season
LookForEpis = `;title`;
LookForPilots = Pilot
PilotsFound = No
Loop, Parse, EpisodeList,`n
{
FileLine = %A_LoopField%
FileLine# = %A_Index%
IfInString, Fileline, %LookForPilots%
{
IfInString, Fileline, http
PilotsFound = No
Else
PilotsFound = Yes
}
IfInString, FileLine, %LookForEpis%
{
IsEpisodes = Yes
Ep_FileLine = %FileLine%
;Episode Title
StringGetPos, EpiTitleLeft, Ep_FileLine, ">
EpiTitleLeftPos := EpiTitleLeft + 3
StringGetPos, EpiTitleRightPos, Ep_FileLine, /a>
EpiTitleAmountToTrim := EpiTitleRightPos - EpiTitleLeftPos
StringMid, EpisodeListTitle, Ep_FileLine, %EpiTitleLeftPos%, %EpiTitleAmountToTrim%
Loop{
IfInString, EpisodeListTitle, <
{
StringGetPos, EpiHTMLTagLeftPos, EpisodeListTitle, <
StringGetPos, EpiHTMLTagRightPos, EpisodeListTitle, >
EpiHTMLTagLeftPos := EpiHTMLTagLeftPos + 1
EpiHTMLTagAmountToTrim := EpiHTMLTagRightPos - EpiHTMLTagLeftPos + 2
StringMid, EpiHTMLTag, EpisodeListTitle, %EpiHTMLTagLeftPos%, %EpiHTMLTagAmountToTrim%
StringReplace, EpisodeListTitle, EpisodeListTitle, %EpiHTMLTag%,
}
Else
Break
}
;Episode Summary Link
StringGetPos, EpiLinkLeftPos, Ep_FileLine, tt
EpiLinkRightPos := EpiTitleLeft + 1
EpiLinkAmountToTrim := EpiLinkRightPos - EpiLinkLeftPos
StringMid, EpisodeSumLinkList, Ep_FileLine, %EpiLinkLeftPos%, %EpiLinkAmountToTrim%
;Episode Date
EpiDateLine# := FileLine# + 3
EpiLoop#++
If PilotsFound = Yes
{
Episode# = Pilot
EpiLoop#--
PilotsFound = No
}
Else
Episode# = %EpiLoop#%
FileAppend, %Episode#%`n%EpisodeListTitle%`n, %SaveDir%EpisodeNames.txt
}
If FileLine# = %EpiDateLine#%
{
EpiDate = %FileLine%
Gui, ListView, EpisodeLV
If PleaseWaitLoop = 0
{
LV_Delete()
LV_Add("Select Focus", Episode#, EpisodeListTitle, EpiDate)
}
Else
LV_Add("", Episode#, EpisodeListTitle, EpiDate)
If PleaseWaitLoop = 0
LV_ModifyCol()
FileAppend, %EpiDate%`n%EpisodeSumLinkList%`n`n, %SaveDir%EpisodeNames.txt
PleaseWaitLoop++
}
}
If IsEpisodes = No
{
Gui, ListView, EpisodeLV
LV_Delete()
LV_Add("", "No Episodes In This Season")
EpisodesListed = No
}
LV_ModifyCol()
LV_ModifyCol(2,120)
EpisodesListed = Yes
return
FindEpisodeSummary:
;GuiControl, ,EpisodeSumTitle,
Loop, Read, %SaveDir%EpisodeNames.txt,
{
FileLine = %A_LoopReadLine%
FileLine# = %A_Index%
If FileLine = %EpisodeSumName%
EpiSumLinkLine# := FileLine# + 2
If FileLine# = %EpiSumLinkLine#%
EpisodeSumLink := FileLine
}
EpiSummaryFile = %SaveDir%%EpisodeTitle%.txt
URLDownloadToFile, %EpisodeSumLink%, %EpiSummaryFile%
FileRead, EpiSummary, %EpiSummaryFile%
FileDelete, %EpiSummaryFile%
EpisodeSum =
EpiSummaryStartFound = No
EpiSummaryFound = No
LookForEpiSum = <div id="main-col">
Loop, Parse, EpiSummary,`n
{
FileLine = %A_LoopField%
FileLine# = %A_Index%
IfInString, FileLine, %LookForEpiSum%
EpiSummaryStartFound = Yes
If EpiSummaryStartFound = Yes
{
If FileLine = <div class="ta-r mt-10 f-bold">
break
StringLen, EpiSumCheckLen, FileLine
EpiSumCheckAmountToTrim := EpiSumCheckLen - 3
StringTrimRight, EpiSumCheckLine, FileLine, %EpiSumCheckAmountToTrim%
If EpiSumCheckLine =
continue
Else IfInString, EpiSumCheckLine, <
{
If EpiSumCheckLine = <b>
GoSub, GetEpisodeSummary
Else
Continue
}
Else
GoSub, GetEpisodeSummary
}
}
StringLen, EpisodeSumName#, EpisodeSumName
Gui, Font,
Gui, Font, Bold
GuiControl, Font,EpisodeSumTitle,
GuiControl, +Center,EpisodeSumTitle,
If EpisodeSumName# < 32
GuiControl, ,EpisodeSumTitle, `n%EpisodeSumName%
else
GuiControl, ,EpisodeSumTitle, %EpisodeSumName%
If EpiSummaryFound = No
GuiControl, , EpisodeSumEdit, No summary was found for this episode.
Else
GuiControl, , EpisodeSumEdit, %EpisodeSum%
Gui, Font, Norm
return
GetEpisodeSummary:
Loop {
IfInString, FileLine, <
{
StringGetPos, HTMLTagLeftPos, FileLine, <
StringGetPos, HTMLTagRightPos, FileLine, >
HTMLTagLeftPos := HTMLTagLeftPos + 1
HTMLTagAmountToTrim := HTMLTagRightPos - HTMLTagLeftPos + 2
StringMid, HTMLTag, FileLine, %HTMLTagLeftPos%, %HTMLTagAmountToTrim%
StringReplace, FileLine, FileLine, %HTMLTag%,
}
Else
{
EpisodeSum = %EpisodeSum%%FileLine%`n`n
EpisodeSumSet = Yes
break
}
}
EpiSummaryFound = Yes
return
ContextAddFavs:
TheFound =
StringLeft, FavShowTheCheck, FavShow, 4
IfInString, FavShowTheCheck, The
{
StringRight, FavShowTheCheck, FavShowTheCheck, 1
If FavShowTheCheck = %A_Space%
{
StringTrimLeft, FavShowThe, FavShow, 4
FavShowThe = %FavShowThe%, The
TheFound = Yes
}
}
IfExist, %FavSaveFolder%TVFavorites.txt
{
Loop, Read, %FavSaveFolder%TVFavorites.txt
{
Fileline = %A_LoopReadLine%
If Fileline = %FavShow%
{
MsgBox, ,Already Saved, This show is already saved in your favorties
return
}
Else
continue
}
}
If BrowseSearchFavs = Search
ShowFile = %SaveDir%%SearchShow%SearchResults.txt
Else If BrowseSearchFavs = Browse
ShowFile = %SaveDir%%BrowseDDLText%ShowNames.txt
ShowLinkLine# = 0
ShowLink =
ShowNameFound = No
ShowLinkFound = No
Loop, Read, %ShowFile%,
{
FileLine = %A_LoopReadLine%
FileLine# = %A_Index%
If FileLine = %FavShow%
ShowLinkLine# := FileLine# + 1
If Fileline# = %ShowNameLine#%
ShowNameFound = Yes
If FileLine# = %ShowLinkLine#%
{
ShowLink := FileLine
ShowLinkFound = Yes
}
}
If TheFound = Yes
ShowName = %FavShowThe%
Else
ShowName := FavShow
FileAppend, %ShowName%`n%ShowLink%`n`n, %FavSaveFolder%TVFavorites.txt
If ErrorLevel <> 0
MsgBox, ,Error, Unable to save your favorites in the designated location.`nPlease select a new location by going to Tool -> Options.
return
ContextRemoveFavs:
ShowLinkLine =
Loop, Read, %FavSaveFolder%TVFavorites.txt, %FavSaveFolder%TVFavoritesTemp.txt
{
Fileline := A_LoopReadLine
Fileline# := A_Index
If Fileline = %FavShow%
{
ShowLinkLine := Fileline# + 1
ShowBlankLine := Fileline# + 2
continue
}
Else If (Fileline# = ShowLinkLine or Fileline# = ShowBlankLine)
continue
Else
FileAppend, %Fileline%`n
}
FileDelete, %FavSaveFolder%TVFavorites.txt
FileMove, %FavSaveFolder%TVFavoritesTemp.txt, %FavSaveFolder%TVFavorites.txt
Gui, ListView, ShowLV
LV_Delete()
GoSub, FavButton
return
SearchShows:
SearchShowLink = http://www.tv.com/search.php?type=11&stype=program&qs=%SearchShow%&tag=filter;tv_shows
SearchShowFile = %SaveDir%SearchFor%SearchShow%Return.txt
IfExist, %SaveDir%%SearchShow%SearchResults.txt
{
FileGetTime, FileTime, %SaveDir%%SearchShow%SearchResults.txt, M
GoSub, CheckTime
If NowTime = 7
{
FileDelete, %SaveDir%%SearchShow%SearchResults.txt
IsFileOld = Yes
return
}
FirstShowFileline# = 2
Loop, Read, %SaveDir%%SearchShow%SearchResults.txt,
{
FileLine = %A_LoopReadLine%
FileLine# = %A_Index%
Gui, ListView, ShowLV
If FileLine# = %FirstShowFileLine#%
{
ShowTitle := FileLine
ShowNameFileline# := FirstShowFileline# + 4
If AllShowsGet = No
LV_Delete()
LV_Add("Select Focus", ShowTitle)
}
Else If FileLine# = %ShowNameFileline#%
{
ShowTitle := FileLine
ShowNameFileline# := ShowNameFileline# + 4
LV_Add("", ShowTitle)
}
}
GuiControl, , ShowsText, Shows: Finished Downloading
return
}
Else
{
URLDownloadToFile, %SearchShowLink%, %SearchShowFile%
If ErrorLevel <> 0
{
Gui, ListView, ShowLV
LV_Delete()
LV_Add("", "Your seach returned no results.")
LV_Add("", "Please check the spelling or try another query.")
ShowsListed = No
return
}
}
FileRead, SearchShowRead, %SearchShowFile%
;Pages
PageLoop# = 1
Page# =
LookForPages = pagination`;
Loop, Parse, SearchShowRead,`n
{
FileLine = %A_LoopField%
FileLine# = %A_Index%
IfInString, FileLine, %LookForPages%
{
IfInString, FileLine, pagination;next
continue
Else
{
Paginations := FileLine
Loop, Parse, Paginations, `;
{
IfInString, A_Loopfield, pagination
PageLoop#++
}
break
}
}
}
Pages := PageLoop#
;Search Show Names
Title#Loop = 0
LookForSrchShwTitle = Show:
Srch_LoopCount = 0
Srch_LoopCountFile = 1
FirstRow = Yes
Gui, ListView, ShowLV
LV_Delete()
Loop, %Pages% {
Srch_Link = http://www.tv.com/search.php?type=11&stype=program&qs=%SearchShow%&pg_results=%Srch_LoopCount%&tag=pagination;%Srch_LoopCountFile%
ShowNamesFile = %SaveDir%%ShowName%SearchPages%Srch_LoopCountFile%.txt
URLDownloadToFile, %Srch_Link%, %ShowNamesFile%
If ErrorLevel <> 0
MsgBox error
FileRead, SearchShowRead, %ShowNamesFile%
FileDelete, %ShowNamesFile%
SearchTitleLoop = 0
Loop, Parse, SearchShowRead,`n
{
Fileline = %A_LoopField%
IfInString, Fileline, %LookForSrchShwTitle%
{
;GetShowName
StringGetPos, ShowTitleLeftPos, Fileline, >, L2
StringGetPos, ShowTitleRightPos, Fileline, <, L3
ShowTitleLeftPos := ShowTitleLeftPos + 2
ShowTitleRightPos := ShowTitleRightPos + 1
ShowTitleLen := ShowTitleRightPos - ShowTitleLeftPos
StringMid, ShowTitle, Fileline, %ShowTitleLeftPos%, %ShowTitleLen%
;Get Show Link
StringGetPos, ShowLinkLeftPos, Fileline, http
StringGetPos, ShowLinkRightPos, Fileline, >%ShowTitle%
ShowLinkLeftPos := ShowLinkLeftPos + 1
ShowLinkAmountToTrim := ShowLinkRightPos - ShowLinkLeftPos
StringMid, ShowLink, Fileline, %ShowLinkLeftPos%, %ShowLinkAmountToTrim%
;Add To Gui
If FirstRow = Yes
{
LV_Delete()
LV_Add("Select Focus", ShowTitle)
FirstRow = No
}
Else
LV_Add("", ShowTitle)
Title#Loop++
SearchTitleLoop++
FileAppend, %Title#Loop%`n%ShowTitle%`n%ShowLink%`n`n, %SaveDir%%SearchShow%SearchResults.txt
}
IfInString, FileLine, Your seach returned no results. Please try another query.
{
Gui, ListView, ShowLV
LV_Delete()
LV_Add("", "Your seach returned no results.")
LV_Add("", "Please try another query.")
return
}
}
Srch_LoopCount++
Srch_LoopCountFile++
}
GuiControl, , ShowsText, Shows: Finished Downloading
ShowsListed = Yes
return
GetAllShowPages:
GoSub, ClearControlsforShowList
ShowBrowseSymbols = 9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z
AllShowsGet = Yes
AllShowsLoop# = 1
Gui, ListView, ShowLV
LV_Delete()
ShowsListed = No
IfExist, %SaveDir%AllShowNames.txt
{
FileGetTime, FileTime, %SaveDir%AllShowNames.txt, M
GoSub, CheckTime
If NowTime = 3
{
FileDelete, %SaveDir%AllShowNames.txt
IsFileOld = Yes
return
}
FirstShowFileline# = 2
Loop, Read, %SaveDir%AllShowNames.txt,
{
FileLine = %A_LoopReadLine%
FileLine# = %A_Index%
If FileLine# = %FirstShowFileLine#%
{
ShowTitle := FileLine
ShowNameFileline# := FirstShowFileline# + 4
LV_Delete()
LV_Add("Select Focus", ShowTitle)
}
Else If FileLine# = %ShowNameFileline#%
{
ShowTitle := FileLine
ShowNameFileline# := ShowNameFileline# + 4
LV_Add("", ShowTitle)
}
}
}
Else
{
Loop, Parse, ShowBrowseSymbols, |
{
ShowsLetter := A_LoopField
IfExist, %SaveDir%%ShowsLetter%ShowNamesTemp.txt
FileDelete, %SaveDir%%ShowsLetter%ShowNamesTemp.txt
IfExist, %SaveDir%%ShowsLetter%ShowNames.txt
GoSub, GetShowNames
Else
GoSub, ListShowPages
}
FileMove, %SaveDir%AllShowNamesTemp.txt, %SaveDir%AllShowNames.txt
}
GuiControl, , ShowsText, Shows: Finished Downloading
AllShowsGet = No
ShowsListed = Yes
return
CheckTime:
FormatTime, NowTime, ,yyyyMMdd
EnvSub, NowTime, %FileTime%, days
return
2GuiClose:
2GuiEscape:
Gui Destroy
return
GuiClose:
GuiEscape:
Gui Destroy
;FileRemoveDir, %SaveDir%ShowPages, 1
exitapp
|
Last edited by BobTom on Sat Aug 30, 2008 8:07 pm; edited 8 times in total |
|
| Back to top |
|
 |
slomz
Joined: 03 Sep 2006 Posts: 608 Location: Iowa, U.S.
|
Posted: Sun Oct 22, 2006 7:40 pm Post subject: |
|
|
Nice script, except...
| Code: | GuiClose:
GuiEscape:
Gui Destroy
FileRemoveDir, c:\tvcom, 1
return |
should be
| Code: | GuiClose:
GuiEscape:
Gui Destroy
FileRemoveDir, c:\tvcom, 1
exitapp |
_________________
 |
|
| Back to top |
|
 |
SoggyDog
Joined: 02 May 2006 Posts: 261 Location: Greeley, CO
|
Posted: Mon Oct 23, 2006 3:34 am Post subject: |
|
|
My family; TV junkies one and all.
We like this script.
 _________________
SoggyDog
Download AutoHotKey Wallpaper
Does 'Fuzzy Logic' tickle? |
|
| Back to top |
|
 |
BobTom
Joined: 27 Aug 2006 Posts: 15 Location: Virginia
|
Posted: Mon Oct 23, 2006 11:30 am Post subject: |
|
|
| slomz wrote: | Nice script, except...
| Code: | GuiClose:
GuiEscape:
Gui Destroy
FileRemoveDir, c:\tvcom, 1
return |
should be
| Code: | GuiClose:
GuiEscape:
Gui Destroy
FileRemoveDir, c:\tvcom, 1
exitapp |
|
Sorry, I had it like that because I was testing it as a hotkey and forgot to put exitapp when I took the hotkey out. Thanks for the heads up. |
|
| Back to top |
|
 |
BobTom
Joined: 27 Aug 2006 Posts: 15 Location: Virginia
|
Posted: Mon Oct 23, 2006 11:30 am Post subject: |
|
|
| SoggyDog wrote: | My family; TV junkies one and all.
We like this script.
 |
Sounds like me, thanks for the reply. |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1718
|
Posted: Mon Oct 23, 2006 12:51 pm Post subject: |
|
|
i checked it out... its nice! i like the clean interface. _________________
 |
|
| Back to top |
|
 |
slomz
Joined: 03 Sep 2006 Posts: 608 Location: Iowa, U.S.
|
Posted: Mon Oct 23, 2006 10:36 pm Post subject: |
|
|
Next you should add a picture box and urldownload the the pic if a episode has it to tht box. _________________
 |
|
| Back to top |
|
 |
sosaited
Joined: 24 Feb 2005 Posts: 233
|
Posted: Tue Oct 24, 2006 8:50 am Post subject: |
|
|
Very Nice Script indeed.
I would love if these features were added:
1. Ability to search Tv Serials (It takes a bit more time to browse, find and select)
2. View Episode Recap.
3. Ability to SAVE list of Episodes, Episode Summary, Episode Recap
I hope you will take some time and implement these as well.
Thanks for the script _________________ My small "thanks" to AHK in shape of these dedicated 3d images (Topic already in "General" Forum)  |
|
| Back to top |
|
 |
BobTom
Joined: 27 Aug 2006 Posts: 15 Location: Virginia
|
Posted: Tue Oct 24, 2006 1:20 pm Post subject: |
|
|
| slomz wrote: | | Next you should add a picture box and urldownload the the pic if a episode has it to tht box. |
I have thought about this option but probably won't try it for a while. Good suggestion
| sosaited wrote: |
Very Nice Script indeed.
I would love if these features were added:
1. Ability to search Tv Serials (It takes a bit more time to browse, find and select)
2. View Episode Recap.
3. Ability to SAVE list of Episodes, Episode Summary, Episode Recap
I hope you will take some time and implement these as well.
Thanks for the script |
I have already put in a search feature and is pretty good but the way I want it yet, I'm finalizing it now
I have thought about the recap and it might be next once I would out some other bugs
I thought about a favorites option before the search option but thought the search would be more important but will eventually get to the favorites
Thanks for the great suggestions!!! |
|
| Back to top |
|
 |
sosaited
Joined: 24 Feb 2005 Posts: 233
|
Posted: Tue Oct 24, 2006 10:35 pm Post subject: |
|
|
I checked the new script with Search function, but it is different from what I meant. I meant to DIrectly Search for a show before even selecting any Alphabet for Show Names.
As:
| Code: | | http://www.tv.com/search.php?qs=smallville&type=11&stype=all&tag=search%3Bbutton |
Apart from that, I've seen that your script deletes all the files once it is closed. I think you should add an option like (Do not use cache) for the cases when New data is required, otherwise previous files can be used which will considerably improve the speed. _________________ My small "thanks" to AHK in shape of these dedicated 3d images (Topic already in "General" Forum)  |
|
| Back to top |
|
 |
BobTom
Joined: 27 Aug 2006 Posts: 15 Location: Virginia
|
Posted: Wed Oct 25, 2006 11:21 am Post subject: |
|
|
| sosaited wrote: | | I checked the new script with Search function, but it is different from what I meant. I meant to DIrectly Search for a show before even selecting any Alphabet for Show Names. |
You can search without browsing. Just type in a search and hit enter and the shows will download
| sosaited wrote: | | I think you should add an option like (Do not use cache) for the cases when New data is required, otherwise previous files can be used which will considerably improve the speed. |
I am planning on doing this but I had it download everytime just so i could get the program working.
Thanks Again! |
|
| Back to top |
|
 |
hiddenmage
Joined: 19 Mar 2006 Posts: 5
|
Posted: Wed Oct 25, 2006 11:13 pm Post subject: |
|
|
Wow, this is an AWESOME script.
Hopefully you'll continue with it and update it to make an even better application. |
|
| Back to top |
|
 |
scriptmonkey
Joined: 19 May 2006 Posts: 112
|
Posted: Thu Nov 02, 2006 2:25 pm Post subject: |
|
|
Pretty cool script. Anyone make one for the IMDB yet  _________________ Zak M. |
|
| Back to top |
|
 |
Ace_NoOne
Joined: 10 Oct 2005 Posts: 333 Location: Germany
|
Posted: Fri Nov 03, 2006 12:27 pm Post subject: |
|
| | |