Download TVBanner Bash Script
#1
OK I was trying to get Banners for my TV Shows. I threw this together and thought I would share it. It can be built upon with a few little tweaks. I will probably work on getting it to recuse search each TV folders and put the banner.jpg in that folder. currently it just downloads it to a single folder (TVDIR variable).

Code:
#!/bin/bash

#############
## VARIABLES
#############

# Make all input lowercase
SEARCH="$(echo ${1} | tr A-Z a-z)"
resultLink=""  # Variable for passing Strings in getResultLink function
bannerLink=""  # Variable for passing Strings in getBannerLink function
TVDIR="/tmp"  #location of TV Root Directory

# Setup for acpting different language searchs
#LANGUAGE="English"
#if "${2}" then LANGUAGE="$(echo ${1} | tr A-Z a-z)"

# Get a dump of the search from thetvdb.com
lynx -dump "http://thetvdb.com/?string=${SEARCH}&searchseriesid=&tab=listseries&function=Search" > /tmp/searchResults.txt

# Create Array of the options returned

i=1
IFS="
"
for line in `grep English /tmp/searchResults.txt`; do
  tmp="$(echo ${line} | tr A-Z a-z | sed -e 's/^[ \t]*//' | sed -e 's/english/:/' | cut -d':' -f1 | sed -e 's/ \{1,\}$//')"
#  echo "line 31 - $i: $tmp"
  ENGLISHARRAY[$i]=$tmp
  (( i++ ))
done

#############
## FUNCTIONS
#############


# listOptions - output of all results and there array number
function listOptions {
  for (( i = 0 ; i < ${#ENGLISHARRAY[@]} ; i++ )); do
    if [[ ${ENGLISHARRAY[$i]} =~ "$SEARCH" ]]
     then
     echo "$i:  ${ENGLISHARRAY[$i]}"
    fi
  done
}

function getResultLink() {
  if [ -z "$1" ]                           # Is parameter #1 zero length?
   then
     echo "-Parameter #1 is zero length.-"  # Or no parameter passed.
   else
     linknum="$(echo ${ENGLISHARRAY[$1]} | sed 's/\[//g;s/\].*//g')"
#     echo "The Link Number is: $linknum" ; echo
     linktmp="$(grep "$linknum. " /tmp/searchResults.txt)"
#     echo "The Linktmp is: $linktmp" ; echo
     resultLink="$(echo $linktmp | sed 's/^[^h]*//g')"
#     echo "***********"
#     echo "$resultLink"
#     echo
   fi
}

function getBannerLink() {
  if [ -z "$1" ]
  then
    echo "-Parameter #1 is zero length.-"  # Or no parameter passed.
  else
    linktmp="$(lynx -dump "$1" | grep -v 'tab=DMCA' | grep -m1 -i 'banners/graphical')"
#    echo "$linktmp"
    if [ -z "$linktmp" ]
    then
      echo "There are no Banners for this TV Series"
      exit
    fi
    bannerLink="$(echo $linktmp | sed 's/^[^h]*//g')"
#    echo "***********"
#    echo "$bannerLink"
#    echo
   fi
}

function downloadBanner() {
  wget -O "$TVDIR/banner.jpg "$1"
}

#############
##MAIN
#############

#count=${#ENGLISHARRAY[@]}
#echo "******"
#echo "$count"

if [ "${#ENGLISHARRAY[@]}" -gt 1 ]
then
  echo
  listOptions
  echo "Choose a matching number and hit enter: "
  read ANSWER
  getResultLink "$ANSWER"
else
  getResultLink 1
fi

getBannerLink "$resultLink"
downloadBanner "$bannerLink"


#Clean temp files and variables
resultLink=""
bannerLink=""
ANSWER=""
rm /tmp/searchResults.txt

Have a great day.

Thanks,
super sobbie
Reply
#2
So what exactly does this do?
Image
To learn more, click here.
Reply
#3
example use:

desktop:~ > tvbd "The Middle"

1: [12]caught in the middle
2: [13]in the middle of nature
3: [14]in the middle of wild germany
4: [16]malcolm in the middle
5: [20]pig in the middle
6: [21]the middle
Choose a matching number and hit enter: ###This prompts you
6 ###if multiple options return
--2010-11-06 06:52:47-- http://thetvdb.com/banners/graphical/95021-g3.jpg
Resolving thetvdb.com... 67.152.32.114
Connecting to thetvdb.com|67.152.32.114|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 94246 (92K) [image/jpeg]
Saving to: `/media/SHARE/TV_Shows/banner.jpg'

100%[==================================================================================================>] 94,246 323K/s in 0.3s

2010-11-06 06:52:48 (323 KB/s) - `/media/SHARE/TV_Shows/banner.jpg' saved [94246/94246]

desktop:~ >


So basically it will give the resulting search options from "thetvdb.com" (currently I only get English) if there are multiple options. Then it will download the first banner available and save it to $TVDIR/banner.jpg. You can then move it to the correct folder. I am working on having it recursively go through the directory's and put the "banner.jpg" file in the correct directory as well but I have not gotten that far. For know it just gets a banner.

It uses "wget" and "lynx" to do most of the work so you would need those installed. Sorry for the short description before I was just put'zing at work and threw that together real quick.

Thanks again,
super_sobbie
Reply
#4
why not using logo downloader script ?
Reply
#5
ppic Wrote:why not using logo downloader script ?

I think this script specifically saves the file as banner.jpg. This could be useful when some people use posters but skins have support for banner.jpg on some views. Just a thought.
Image
To learn more, click here.
Reply
#6
igotdvds Wrote:I think this script specifically saves the file as banner.jpg. This could be useful when some people use posters but skins have support for banner.jpg on some views. Just a thought.

ok, and what do you thinks logo downloader do ?

Code:
<onclick>XBMC.RunScript(script.logo-downloader,mode=bulk,clearart=True,logo=True,showthumb=landscape.jpg,poster=poster.jpg,banner=banner.jpg)</onclick>
Reply
#7
ppic Wrote:ok, and what do you thinks logo downloader do ?

Code:
<onclick>XBMC.RunScript(script.logo-downloader,mode=bulk,clearart=True,logo=True,showthumb=landscape.jpg,poster=poster.jpg,banner=banner.jpg)</onclick>


I dont know... I never heard of LOGO Downloader and I do not see you posting a link to it so I am not sure what you are talking about.

I did search for a script to download banner.jpg files and I tried to use media companion but it did not give me the results that I wanted. Also "LOGO" is different then "BANNER". if you dont know what I am talking about then that is too bad.

Sorry for what sounds like a rude comment. I just threw this together very quickly to give me the file "banner.jpg" file that I wanted. Also, as I said a Logo is different then a banner so I am not exactly sure what you are talking about. I used the LOGO download script from the Night Skin and it gave me a logo.jpg file with a small logo of the tv show, but I wanted the BANNER.

Smile

Thanks,
supersobbie
Reply
#8
ppic Wrote:ok, and what do you thinks logo downloader do ?

Code:
<onclick>XBMC.RunScript(script.logo-downloader,mode=bulk,clearart=True,logo=True,showthumb=landscape.jpg,poster=poster.jpg,banner=banner.jpg)</onclick>

I didnt know this was added, oops. Huh
Image
To learn more, click here.
Reply
#9
super sobbies:
check link in my sign for logo downloader!
now it's support more than logo !
Reply
#10
Thanks, that was not there when I was playing with it... or I did not know it was. I will take another look at it.

Smile

supersobbie

ppic Wrote:super sobbies:
check link in my sign for logo downloader!
now it's support more than logo !
Reply

Logout Mark Read Team Forum Stats Members Help
Download TVBanner Bash Script0