This file is indexed.

/usr/share/anyremote/cfg-data/Utils/imdb-mf.sh is in anyremote-data 6.3.2-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
#!/bin/bash
#Movie fetcher
#Movie data fetcher developed by Unni <unnikrishnan.a@gmail.com>
#Code to fetch poster, machine readable output and bug fixes by
#Mikhail Fedotov <anyremote@mail.ru>
#http://prj.mutexes.org/projects/imdbmoviefetcher
#version 4.2
shopt -s -o nounset
#Global variable declarations
declare -rx MYSITE="http://prj.mutexes.org/projects/imdbmoviefetcher"
declare -rx SOURCE_REPO="https://github.com/webofunni/imdb-movie-fetcher"
declare -rx SCRIPT=${0##*/}
declare -rx VERSION="4.2"
declare URL
declare TITLE
declare YEAR
declare RATING
declare PLOT
declare MOVIE
declare POSTER=0
declare PARSEABLE=0
declare SIMILAR=1
declare DIRECTOR
declare GENRE
declare CAST
declare POSTERURL
declare -rx TMPFILE=/tmp/imdbmoviefetcher.$$
declare -rx PLOTFILE=/tmp/plot.$$.html
declare -rx LYNX="/usr/bin/lynx"
declare -rx SED="/bin/sed"
declare -rx EGREP="/bin/egrep"
declare -rx GREP="/bin/grep"
declare SWITCH
declare -r OPTSTRING=":hvpmst:"
declare -i INEEDCOLOR
declare TITLECOLOR="White"
declare DATACOLOR="White"
declare LINKCOLOR="White"
declare CONFFILE="/etc/imdb-mf.conf"
declare COLOR_START=""
declare COLOR_END=""
INEEDCOLOR=0

#Get color for colorised output
if [ -f $HOME/.imdb-mf.conf ]
then
  CONFFILE=$HOME/.imdb-mf.conf 
fi

if [ -f $CONFFILE ]
then 
  declare COLOR_START='\033['
  declare COLOR_END='\033[0m'
  . $CONFFILE
fi

getcolor()
{
  COMPONENT=$1
  VAR=$2
  case $COMPONENT in
  Black) eval ${VAR}_CODE=30
        eval ${VAR}_MODE=0
        ;;
  Red)eval ${VAR}_CODE=31
      eval ${VAR}_MODE=0
      ;;
  Green)eval ${VAR}_CODE=32
      eval ${VAR}_MODE=0
     ;;
  Yellow)eval ${VAR}_CODE=33
      eval ${VAR}_MODE=0
  ;;
  Blue)eval ${VAR}_CODE=34
      eval ${VAR}_MODE=0
  ;;
  Purple)eval ${VAR}_CODE=35
      eval ${VAR}_MODE=0
  ;;
  Cyan)eval ${VAR}_CODE=36
      eval ${VAR}_MODE=0
  ;;
  Gray)eval ${VAR}_CODE=37
      eval ${VAR}_MODE=0
  ;;
  DGray)eval ${VAR}_CODE=30
      eval ${VAR}_MODE=1
  ;;
  DRed)eval ${VAR}_CODE=31
      eval ${VAR}_MODE=1
  ;;
  DGreen)eval ${VAR}_CODE=32
      eval ${VAR}_MODE=1
  ;;
  DYellow)eval ${VAR}_CODE=33
      eval ${VAR}_MODE=1
  ;;
  DBlue)eval ${VAR}_CODE=34
      eval ${VAR}_MODE=1
  ;;
  DPurple)eval ${VAR}_CODE=35
      eval ${VAR}_MODE=1
  ;;
  DCyan)eval ${VAR}_CODE=36
      eval ${VAR}_MODE=1
  ;;
  White)eval ${VAR}_CODE=37
      eval ${VAR}_MODE=1
  ;;
  *)eval ${VAR}_CODE=37
  eval ${VAR}_MODE=0
  ;;
  esac
}
#End of colorse function

if [ $INEEDCOLOR -eq 1 ]
then
  getcolor $TITLECOLOR TITLECOLOR
  getcolor $DATACOLOR DATACOLOR
  getcolor $LINKCOLOR LINKCOLOR
else
  TITLECOLOR=""
  DATACOLOR=""
  LINKCOLOR=""
fi

#check the input arguments/ parametrs
if [ $# -eq 0 ]
then
  printf "%s -h for more information\n" "$SCRIPT"
  exit 192
fi

while getopts "$OPTSTRING" SWITCH;do
case "$SWITCH" in
h) cat << EOF
Usage: $SCRIPT [option] [arg]
Get movie details without leaving bash

Options : 
   -v : gives the version of the script
   -h : shows the help page
   -t [arg] : Pass the movie title as argument. It is recommended to quote the name as shown in the example below 
   -p : Download movie poster. Use it with -t option.
   -s : Do not show similar titles.
   -m : Output in machine-readable format, easy for subsequent parsing. Use it with -t option.

Example : 
   $SCRIPT -t "cars"
 
Bugs, feature requests etc : $MYSITE
Source code : $SOURCE_REPO   
EOF
   exit 0
   ;;
t) MOVIE="$OPTARG"
   ;;
p) POSTER="1"
   ;;
s) SIMILAR="0"
   ;;
m) PARSEABLE="1"
   INEEDCOLOR="0"
   ;;
v) printf "IMDB movie fetcher version %s.\n\nBugs, Feature requests etc : %s\nSource code : %s\n" "$VERSION" "$MYSITE" "$SOURCE_REPO"
   exit 0
   ;;
\?) printf "%s\n" "Invalid option. use $SCRIPT -h for more information"
    exit 192
    ;;
*) printf "%s\n" "Invalid argument. use $SCRIPT -h for more information"
   exit 192
    ;;
esac
done

[[ ${MOVIE:-unset} == 'unset' || -z $MOVIE ]] && { printf "Invalid input. Execute %s -h for more information\n" "$SCRIPT";exit 192;}

#functions
printnofound() {
  printf "There is no $1 command. Please install it\n"
}

sancheck() {
  BINARY=$1
  if [ ! -x "$BINARY" ]
  then
  printnofound $BINARY >&2
  exit 192
  fi
}

#Sanity checks
if [ -z "$BASH" ]
then
  printf "This script is written for bash. Please run this under bash\n" >&2
  exit 192
fi

# do sancheck only for utilities which absent in coreutils package
sancheck $LYNX
sancheck $EGREP
sancheck $GREP
sancheck $SED
#sanity check finished

#replace special characters in the movie name argument
MOVIE=`echo $MOVIE | sed -r 's/  */\+/g;s/\&/%26/g;s/\++$//g'`
#search the title in google
$LYNX -connect_timeout=10 --source "http://www.google.com/search?hl=en&q=$MOVIE+imdb" > $TMPFILE 2> /dev/null
#Check if lynx is successful
if [ $? -ne 0 ]
then 
  printf "Connection to site failed...Please check your internet connection\n"
  exit 192
fi


#Get IMDB URL for the film
URL=`$EGREP -o "http://www.imdb.com/title/tt[0-9]*/" $TMPFILE | head -1`
#Get similar titles
SIMILARTITLES=`egrep -o "<a[^>]+>[^<]*(<b>[^<|^(imdb)]+</b>)*[^<]*<b>[^<]*</b>[^\(|^<]*\([0-9]+\)[^-]+-[^<]*<b>IMDb</b>" $TMPFILE | grep "www.imdb.com" | sort | uniq | sed 's/- <b>IMDb<\/b>//g' | sed 's/<[^>]*>//g'`

#get the details from movie page
$LYNX --source ${URL} > $TMPFILE;
if [ $? -ne 0 ]
then 
  printf "Connection to site failed...Please check your internet connection\n"
  exit 192
fi

#extract data
#YEAR=`cat $TMPFILE | $SED -n '/<h1.*>/,/<\/h1>/p' | $SED -n '/<span.*>/,/<\/span>/p' | $SED '/^$/d;s/<[^>]*>//g;s/(//g;s/)//g' | $SED 's/&ndash;/ - /g'| $EGREP -o "[0-9][0-9][0-9][0-9]( - [0-9][0-9][0-9][0-9])*"`
#TITLE=`cat $TMPFILE | $SED -n '/<h1.*>/,/<\/h1>/p' | $SED '1d;$d;/^$/d;s/<[^>]*>//g;s/(//g;s/)//g' | head -1 | $SED "s/\&#x27\;/\'/g"`

# update Feb 20 2013
YEAR=`cat $TMPFILE | $SED -n '/<h1.*>/,/<\/h1>/p' | $SED -n '/<span class="nobr".*>/,/<\/span>/p' | $SED '/^$/d;s/<[^>]*>//g;s/(//g;s/)//g' | $SED 's/&ndash;/ - /g'|tr -d ' '`
TITLE=`cat $TMPFILE | $SED -n '/<h1.*>/,/<\/h1>/p' | $SED -n 's/.*itemprop="name">//;s/<.*//p' |tr -s ' '|tr '\n' ' '`

POSTERURL=`grep "Poster" $TMPFILE -A1|grep -o http.*\.jpg|cut -f 1 -d "_"`
POSTERURL=${POSTERURL}jpg

if [ $POSTER -eq 1 ] 
then
  POSTERFILE=`echo $TITLE | $SED "s/ /_/g"`
  $LYNX -connect_timeout=10 --source $POSTERURL > ${POSTERFILE}.jpg 2> /dev/null
fi

RATING=`$SED -n '/<span itemprop="ratingValue">/{ s/<[^>]*>//g;p;}' $TMPFILE  | $EGREP -o "[0-9]+\.[0-9]+/[0-9]+" | tail -1`;

#Get the plot in a html file
#$SED -n '/<h1.*>/,/<\/p>/p' $TMPFILE | $SED -n '/<p>/,/<\/p>/{ s/<[^>]*>//g;p;}' | $SED 's/See full summary.*//g' > $PLOTFILE 
$SED -n '/.*<p itemprop="description">/,/<\/p>/p' $TMPFILE | $SED -n 's/.*itemprop="description">//;s/<.*//p' > $PLOTFILE 
PLOT=`lynx --dump $PLOTFILE | sed 's/^  *//g'`

#DIRECTOR=`$SED -n '/ *Director[s]*:.*/,/ *Writer[s]*:.*/{p;}' $TMPFILE | $SED -n '/ *Director[s]*:.*/,/ *Star[s]*:.*/{p;}' | $SED '1d;$d' | tr '\n' ' ' | $SED 's/<[^>]*>//g;s/^ *//g;s/ *$//g;s/&nbsp;&raquo;//g'`
#GENRE=`$SED -n '/genre/p' $TMPFILE | $EGREP -o '<a  *.*href="/genre/[a-zA-Z][a-z]*"[^>]*>[^<]*</a>' | $SED 's/<[^>]*>//g;s/&nbsp\;//g;s/ *Genres *[0-9][0-9]* *min-//g;s/|/,/g' | $SED 's/[gG]enres//g;s/^  *//g' | uniq | head -1`
#CAST=`$SED -n '/.*Star[s]*:.*/,/<\/div>/{ s/<[^>]*>//g;s/Stars://g;p }' $TMPFILE | grep -v "See full cast and crew" | $SED -n '/^ *$/d;p' | tr '\n' ' ' | $SED 's/<[^>]*>//g;s/|//g'`

# update Feb 20 2013
DIRECTOR=`$SED -n '/ *tt_ov_dr.*/,/<\/div>/{p;}' $TMPFILE|$SED -n 's/.*itemprop="name">//;s/<.*//p'|sort -u|tr -s ' '|tr '\n' ','|sed 's/ ,//g;s/^,//;s/,$//'`
GENRE=`grep "ref_=tt_ov_inf" $TMPFILE| grep genre|$SED -n 's/.*itemprop="genre">//;s/<.*//p'|sort -u|tr '\n' ','|sed 's/^,//;s/,$//'`
CAST=`$SED -n '/ *tt_ov_st.*/,/<\/div>/{p;}' $TMPFILE|$SED -n 's/.*itemprop="name">//;s/<.*//p'|sort -u|tr -s ' '|tr '\n' ','|sed 's/ ,//g;s/^,//;s/,$//'`

if [ $INEEDCOLOR -eq 1 ] 
then
  TITLE_COLOR_TAG="${TITLECOLOR_MODE};${TITLECOLOR_CODE}m"
  DATA_COLOR_TAG="${DATACOLOR_MODE};${DATACOLOR_CODE}m"
  LINK_COLOR_TAG="${LINKCOLOR_MODE};${LINKCOLOR_CODE}m"
else
  TITLE_COLOR_TAG=""
  DATA_COLOR_TAG=""
  LINK_COLOR_TAG=""
fi

if [ $PARSEABLE -eq 1 ] 
then
  PLOT=`echo $PLOT | tr -d '\n'`
fi

#print everything
printf "\n${COLOR_START}${TITLE_COLOR_TAG}Title${COLOR_END}      : ${COLOR_START}${DATA_COLOR_TAG}$TITLE${COLOR_END}\n"
printf "${COLOR_START}${TITLE_COLOR_TAG}Year${COLOR_END}       : ${COLOR_START}${DATA_COLOR_TAG}$YEAR${COLOR_END}\n"
printf "${COLOR_START}${TITLE_COLOR_TAG}Rating${COLOR_END}     : ${COLOR_START}${DATA_COLOR_TAG}$RATING${COLOR_END}\n"
printf "${COLOR_START}${TITLE_COLOR_TAG}Director${COLOR_END}   : ${COLOR_START}${DATA_COLOR_TAG}$DIRECTOR${COLOR_END}\n"
printf "${COLOR_START}${TITLE_COLOR_TAG}Genres${COLOR_END}     : ${COLOR_START}${DATA_COLOR_TAG}$GENRE${COLOR_END}\n"
printf "${COLOR_START}${TITLE_COLOR_TAG}Cast${COLOR_END}       : ${COLOR_START}${DATA_COLOR_TAG}$CAST${COLOR_END}\n"
printf "${COLOR_START}${TITLE_COLOR_TAG}Plot${COLOR_END}       : ${COLOR_START}${DATA_COLOR_TAG}%s${COLOR_END}\n" "$PLOT"
printf "\n${COLOR_START}${TITLE_COLOR_TAG}IMDB movie URL${COLOR_END} : ${COLOR_START}${LINK_COLOR_TAG}${URL}${COLOR_END}\n"
printf "${COLOR_START}${TITLE_COLOR_TAG}Poster URL${COLOR_END} : ${COLOR_START}${LINK_COLOR_TAG}${POSTERURL}${COLOR_END}\n"

if [ $SIMILAR -eq 1 ] 
then
  if [ $PARSEABLE -eq 0 ] 
  then
    printf "${COLOR_START}${TITLE_COLOR_TAG}\n==============Other similar Titles=============${COLOR_END}\n\n"
    if [ -z "$SIMILARTITLES" ]
    then
      SIMILARTITLES="Nothing interesting here"
    fi
    printf "${COLOR_START}${DATA_COLOR_TAG}%s${COLOR_END}\n" "$SIMILARTITLES"
    printf "\n${COLOR_START}${TITLE_COLOR_TAG}Use above key words to know more about them${COLOR_END}\n"
  else
    if [ ! -z "$SIMILARTITLES" ]
    then
      printf "%s" "$SIMILARTITLES" > $TMPFILE.sim
      cat $TMPFILE.sim|xargs -i echo "Similarities : "{}
      rm -f $TMPFILE.sim > /dev/null   
    fi
  fi
fi

#Done. Now do cleanup
rm $TMPFILE > /dev/null
rm $PLOTFILE > /dev/null
exit 0