Sign up here and you can log into the forum!

LINKSHEETS for IDIOTS

Everything (else) to do with Movie Sheets and homebrew firmware on the WDTV(s), including how the %*#^ do I get them working?

Re: LINKSHEETS for IDIOTS   

Postby sdotech01 » Fri Oct 05, 2012 12:53 pm

ok so i was able to get one drive showing up with the sheets by manually running

/conf/linksheets.pl /tmp/media/usb/USB2/EEE0B450E0B420AF/

i have 2 other drives as well. will i have to manually run this as well or do i have to connect all possible drives, browse through media, grab all the uuid's from the drives i connect and add those lines to my s00 script?
sdotech01
Donor
 
Posts: 54
Joined: Tue Jun 14, 2011 11:58 am

Re: LINKSHEETS for IDIOTS   

Postby sdotech01 » Fri Oct 05, 2012 1:20 pm

after running the linksheets command manually on the correct path, i did a "ls -al /msheets/" command and looking through all of the sheets you can see that it is hit and miss. some of the sheets are valid and others aren't

lrwxrwxrwx 1 root root 58 Dec 31 16:08 The Illusionist.mkv -> /tmp/media/usb/WDLXTV/Movies/The Illusionist.mkv_sheet.jpg
lrwxrwxrwx 1 root root 71 Dec 31 16:09 The Informant.mkv -> /tmp/media/usb/USB2/EEE0B450E0B420AF/Comedy/The Informant.mkv_sheet.jpg
lrwxrwxrwx 1 root root 58 Dec 31 16:08 The Interpreter.mkv -> /tmp/media/usb/WDLXTV/Movies/The Interpreter.mkv_sheet.jpg
lrwxrwxrwx 1 root root 55 Dec 31 16:08 The Invasion.mkv -> /tmp/media/usb/WDLXTV/Movies/The Invasion.mkv_sheet.jpg
lrwxrwxrwx 1 root root 53 Dec 31 16:08 The Island.mkv -> /tmp/media/usb/WDLXTV/Movies/The Island.mkv_sheet.jpg


not really sure what is causing this. i have run "rm -f /msheets/*" before each startup just to make sure the sheets are all new from the script but been having 0 luck getting all sheets to show.
sdotech01
Donor
 
Posts: 54
Joined: Tue Jun 14, 2011 11:58 am

Re: LINKSHEETS for IDIOTS   

Postby recliq » Fri Oct 05, 2012 1:30 pm

All the red files are dead links...

Try this:

Tohave consistent mount points, early mount the drives by creating an empty file named .mnt in th eroot of each drive.
You will see a mount for each drive under /tmp/mnt/<UUID of the drive>. Use the S99custom script to run linksheets on those dirs.
­WDLXTV Project Maintainer
-:] If you like my contributions feel free to donate for a beer or a new flash drive. ...and always remember: RTFM! (README, FAQ, WIKI) [:-
User avatar
recliq
WDLXTV Team
 
Posts: 5513
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: LINKSHEETS for IDIOTS   

Postby sdotech01 » Fri Oct 05, 2012 1:33 pm

recliq wrote:All the red files are dead links...

Try this:

Tohave consistent mount points, early mount the drives by creating an empty file named .mnt in th eroot of each drive.
You will see a mount for each drive under /tmp/mnt/<UUID of the drive>. Use the S99custom script to run linksheets on those dirs.


ok. sorry not a linux guy so eroot is the root of the drive correct?

also i would place this in there multiple times obviously changing usb2 to usb1 where needed? also what if one of the drive isn't connected at that time. will it just skip it?

/conf/linksheets.pl /tmp/media/usb/USB2/UUID/
/conf/linksheets.pl /tmp/media/usb/USB2/DIFF_UUID/
/conf/linksheets.pl /tmp/media/usb/USB1/UUID/
sdotech01
Donor
 
Posts: 54
Joined: Tue Jun 14, 2011 11:58 am

Re: LINKSHEETS for IDIOTS   

Postby sdotech01 » Fri Oct 05, 2012 2:07 pm

created the .mnt file, restarted and looked under /tmp/mnt but all i see is apps.
sdotech01
Donor
 
Posts: 54
Joined: Tue Jun 14, 2011 11:58 am

Re: LINKSHEETS for IDIOTS   

Postby KAD » Fri Oct 05, 2012 2:25 pm

they will still be mounted under /tmp/media/usb/

they just get mounted differently when using the .mnt file
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: LINKSHEETS for IDIOTS   

Postby sdotech01 » Fri Oct 05, 2012 2:30 pm

KAD wrote:they will still be mounted under /tmp/media/usb/

they just get mounted differently when using the .mnt file


ok. thank you. so this is what i have. tried it without the chmod line and i got a permission denied error so back in it went. are the third and fourth lines the correct order or should they be switched. i understand line 3 is telling it to run that command on that directory but what is the 4th line stating. want to make sure i have it all in order and i'm trying my hardest to understand what it means.

#!/bin/sh
chmod a+x /conf/linksheets.pl
/conf/linksheets.pl /tmp/mnt/EEE0B450E0B420AF/
mount --bind /conf/linksheets.pl /usr/bin/linksheets
sdotech01
Donor
 
Posts: 54
Joined: Tue Jun 14, 2011 11:58 am

Re: LINKSHEETS for IDIOTS   

Postby sdotech01 » Fri Oct 05, 2012 2:40 pm

i have no idea why some of the sheets are coming from one directory and some are coming from another that doesn't exits

lrwxrwxrwx 1 root root 67 Dec 31 16:01 Wrong Turn 3 (2009).mkv -> /tmp/mnt/EEE0B450E0B420AF//Horror/Wrong Turn 3 (2009).mkv_sheet.jpg
lrwxrwxrwx 1 root root 67 Dec 31 16:01 Wrong Turn 4 (2011).avi -> /tmp/mnt/EEE0B450E0B420AF//Horror/Wrong Turn 4 (2011).avi_sheet.jpg
lrwxrwxrwx 1 root root 53 Dec 31 16:02 X Files 1.mkv -> /tmp/media/usb/WDLXTV/BoxSets/X Files 1.mkv_sheet.jpg
lrwxrwxrwx 1 root root 71 Dec 31 16:02 X Files 2 I Want To Believe.avi -> /tmp/media/usb/WDLXTV/BoxSets/X Files 2 I Want To Believe.avi_sheet.jpg


S99user-script
Code: Select all
#!/bin/sh
chmod a+x /conf/linksheets.pl
/conf/linksheets.pl /tmp/mnt/EEE0B450E0B420AF/
mount --bind /conf/linksheets.pl /usr/bin/linksheets


linksheets.pl
Code: Select all
#!/usr/bin/perl

### Copyright 2012 b-rad.cc
### http://wdlxtv.com & http://b-rad.cc & http://nextdimension.cc
### GPLv3 - full license located @ /usr/share/LICENSE
### Stipulations:
### - the full copyright notices in /osd/setup_about.xml must be left intact, as it is the publicly displayed copyright portion of this software as dictated by the GPLv3
### - this entire header must be left intact

## linksheets <location> <mode> [/msheets]
##  recursively searches and symlinks movie sheets into /msheets
##  /msheets is joined with /osd via unionfs
##  -- if <mode>  is 1 or 2 then max-levels=<mode>
##  if [/msheets] is provided then that's where the links are created (for testing)
##
## valid types
##  video thumb view:
##  audio thumb view:
##  list mode:
##   - STD
##   - SHEET
##   - WALL
##

use strict;
use File::Basename;
use Cwd 'realpath';

# utility function for controlling the led
sub set_power_led{
    my $mode = shift;
    open(my $fh, ">>", "/proc/led");
    print $fh "power led $mode\n";
    close($fh);
}

# test to see if a string starts with a '.'
sub starts_with_dot{
    $_ = shift;
    if ( /^\./ ) {
        return 1;
    }
    return 0;
}

if ( ! -e $ARGV[0] ) {
    print ("PATH: " . $ARGV[0] . " does not exist!\n");
    system("logger -t linksheets \"$ARGV[0] not found, exiting immediately!!!\"");
    exit 2
}

my $MODE = $ARGV[1];

if ( -e '/tmp/STOP_DMARENDER' ) {
    print "stop\n";
    system("logger -t linksheets \"/tmp/STOP_DMARENDER exists, exiting immediately!!!\"");
    exit 55
}

# parse config file into environment (so that it augments env)
open(my $fh, "<", "/conf/config");
while (!eof($fh)) {
    my $inline = readline($fh);
    if ($inline =~ /LISTNUM/ ||
        $inline =~ /GENTHUMBS/ ||
        $inline =~ /THUMBRESO/ ||
        $inline =~ /MSHEET/ ||
        $inline =~ /DEFAULTSHEET/) {
        chomp($inline);
        (my $var, my $val) = split("=", $inline);
        $val =~ s/'//g;
        #print ($var . "=" . $val . "\n");
        $ENV{$var} = $val
    }
}
close($fh);

# now extract the parameters from the augmented environment
my $MSHEETMODE   = $ENV{'MSHEETMODE'};
my $GENMSHEET    = $ENV{'GENMSHEET'};
my $VIDMSHEET    = $ENV{'VIDMSHEET'};
my $LISTMSHEET   = $ENV{'LISTMSHEET'};
my $DEFAULTSHEET = $ENV{'DEFAULTSHEET'};
my $LDEBUG       = $ENV{'LDEBUG'};

# check that MSHEETMODE is legal
if ( $MSHEETMODE ne "wall" && $MSHEETMODE ne "sheet" && $MSHEETMODE ne "std" ) {
    print "illegal MSHEETMODE\n";
    system("logger -t linksheets \"illegal MSHEETMODE $MSHEETMODE, exiting immediately!!!\"");
    exit 3;
}

# check that one of the sheet modes is active
if ( $GENMSHEET ne "ON" && $VIDMSHEET ne "ON" && $LISTMSHEET ne "ON" && $MODE ne "5" ) {
    print "no generation mode selected\n";
    system("logger -t linksheets \"no generation mode selected, exiting immediately!!!\"");
    exit 3;
}

# configure the per-mode sheet pattern
my $SEARCHSTRING = ".*_sheet.$MSHEETMODE.jpg";

# setup the 'find' argument that will control the depth of it's recursive search
my $DEPTH = "";
if ( $MODE eq "1" || $MODE eq "2" ) {
    $DEPTH = "-maxdepth " . $MODE;
}

system("logger -t linksheets \"Generating MovieSheets for " . $ARGV[0] . ", mode " . $ARGV[1] . "\"");

set_power_led('blink on');

if ( $DEFAULTSHEET ne "" && ! -l "/tmp/defaultsheet.jpg" ) {
    # if the valut of DEFAULTSHEET starts with a / then it's
    # a full path and we want to use it exactly, otherwise
    # assume it's a path relative to /osd/
    $_ = $DEFAULTSHEET;
    if ( /^\// ) {
        symlink($DEFAULTSHEET, "/tmp/defaultsheet.jpg");
    } else {
        symlink("/osd/" . $DEFAULTSHEET, "/tmp/defaultsheet.jpg");
    }
}

# for testing, allow setting of a location to generate the links
if ( $#ARGV == 2 ) {
    chdir($ARGV[2]);
} else {
    chdir("/msheets");
}

# keep track of things we'll only link as a last resort
my %soft_links;

# make sure the link replaces the thing it currently points to
sub force_symlink{
    my $src = shift;
    my $dst = shift;
    my $dbg = shift;
    if ( -e $dst ) {
   my $curr = realpath($dst);
   if ( $curr eq $src ) {
       return;
   }
   if ( $LDEBUG ne "" ) {
       # for the purposes of logging, don't mention it if the files
       # have the same size, ie: assume the user's name space does
       # this for a sane reason
       (my $src_dev,my $src_ino,my $src_mode,my $src_nlink,
        my $src_uid,my $src_gid,my $src_rdev,my $src_size,
        my $src_atime,my $src_mtime,my $src_ctime,
        my $src_blksize,my $src_blocks) = stat($src);
       (my $curr_dev,my $curr_ino,my $curr_mode,my $curr_nlink,
        my $curr_uid,my $curr_gid,my $curr_rdev,my $curr_size,
        my $curr_atime,my $curr_mtime,my $curr_ctime,
        my $curr_blksize,my $curr_blocks) = stat($curr);
       if ($src_size == $curr_size) {
      # assume it's the same image
       } else {
      print "change mind: " . $src . "\n";
      print "           : " . $curr . "\n";
      print "           : " . $dst . "\n";
       }
   }
        unlink($dst);
    }
    symlink($src, $dst);
}

my $find_cmd = "find $ARGV[0]/ -type f $DEPTH ";
$find_cmd .= "-regextype posix-egrep ";
$find_cmd .= "-iregex \".*_sheet.jpg|.*wd_tv.jpg|" . $SEARCHSTRING . "\"";
open(my $fh, $find_cmd . " 2>/dev/null |");
while (!eof($fh)) {
    my $msheet = readline($fh);
    chomp($msheet);
    my $basename_msheet = basename($msheet);
    if ( $MSHEETMODE ne "std" && ($basename_msheet eq "wd_tv.jpg" ||
                                  $basename_msheet eq ".wd_tv.jpg") ) {
        # special handling for [.]wd_tv.jpg:
        #    just link it as it's folder name
        my $DIRNAME = basename(dirname($msheet));
        if ( ! starts_with_dot($DIRNAME) ) {  # skip invisible dirs
            force_symlink($msheet, $DIRNAME,"l1 ");
            if ( $LDEBUG ne "" ) { print "l1  $msheet -> $DIRNAME\n"; }
        }
    } elsif ( $MSHEETMODE ne "std" && ($basename_msheet eq "folder.jpg_sheet.jpg" ||
                                       $basename_msheet eq ".folder.jpg_sheet.jpg" ) ) {
        # special handling for [.]folder.jpg_sheet.jpg
        #    just link it as it's folder name if there is no $MSHEETMODE.jpg form
        #    (as we intend to use that one in instead as the sheet for $DIRNAME)
        my $NOEXT = substr($msheet,0,-4);
        if ( ! -f "$NOEXT.$MSHEETMODE.jpg" ) {
            my $DIRNAME = basename(dirname($msheet));
            if ( ! starts_with_dot($DIRNAME) ) {  # skip invisible dirs
                force_symlink($msheet, $DIRNAME, "l2 ");
                if ( $LDEBUG ne "" ) { print "l2  $msheet -> $DIRNAME\n"; }
            }
        }
    } elsif ( substr($msheet,-10) eq "_sheet.jpg" ) {
        # handle all images that end in _sheet.jpg
        my $BASENAME = basename($msheet, "_sheet.jpg");
        $BASENAME =~ s/^\.//;   # remove leading '.' (if it exists)
        my $NOEXT = substr($msheet, 0, -4);
        my $DIRPATH = dirname($msheet);
        my $DIRNAME = basename($DIRPATH);
        if ( $MSHEETMODE eq "std" ) {
            # it is not clear what this is trying to do or if it makes any sense
            my $BASELINK = basename(realpath($DIRNAME));
            if ( $BASELINK ne "" && substr($BASELINK,0,-10) ne $DIRNAME ) {
                unlink($DIRNAME);
                if ( $LDEBUG ne "" ) { print "ul3 $msheet -> $DIRNAME\n"; }
            }
        } else {
            # link in as folder sheet if a more specialized form do not exist
            if ( starts_with_dot($DIRNAME) ) {
                # skip invisible dirs
            } elsif ( ! -f "$NOEXT.$MSHEETMODE.jpg" &&
                      ! -f "$DIRPATH/folder.jpg_sheet.jpg" &&
                      ! -f "$DIRPATH/folder.jpg_sheet.$MSHEETMODE.jpg" ) {
                if ( $BASENAME eq $DIRNAME ) {
                    # exact name match, do nothing, the 'l3a' link will pick it up
                } elsif ( ! -e $DIRNAME ) {
                    # inexact name match, record that we'll make the link
                    # but don't do so until all other possible matches
                    # have been attempted
                    $soft_links{$DIRNAME} = $msheet;
                }
            }
        }
        # link in as file sheet if a more specialized form do not exist
        if ( ! -f "$NOEXT.$MSHEETMODE.jpg" ) {
            force_symlink($msheet, $BASENAME, "l3a");
            if ( $LDEBUG ne "" ) { print "l3a $msheet -> $BASENAME\n"; }
        }
    } else {
        # handle all other images
        my $BASENAME = basename($msheet,"_sheet.$MSHEETMODE.jpg");
        $BASENAME =~ s/^\.//g;    # remove leading '.' (if it exists)
        my $DIRPATH = dirname($msheet);
        my $DIRNAME = basename($DIRPATH);
        if ( $MSHEETMODE eq "std" ) {
            # it is not clear what this is trying to do or if it makes any sense
            my $BASELINK = basename(realpath($DIRNAME));
            if ( $BASELINK ne "" && substr($BASELINK,0,-(11+length($MSHEETMODE))) ne $DIRNAME ) {
                unlink($DIRNAME);
                if ( $LDEBUG ne "" ) { print "ul4 $msheet -> $DIRNAME\n"; }
            }
        } else {
            # link in as folder sheet if a more specialized form do not exist
            if ( starts_with_dot($DIRNAME) ) {
                # skip invisible dirs
            } elsif ( ! -f "$DIRPATH/folder.jpg_sheet.jpg" &&
                      ! -f "$DIRPATH/folder.jpg_sheet.$MSHEETMODE.jpg" ) {
                if ( $BASENAME eq $DIRNAME ) {
                    # exact name match, do nothing, the 'l4a' link will pick it up
                } elsif ( ! -e $DIRNAME ) {
                    # inexact name match, record that we'll make the link
                    # but don't do so until all other possible matches
                    # have been attempted
                    $soft_links{$DIRNAME} = $msheet;
                }
            }
        }
        # link in as file sheet
        force_symlink($msheet, $BASENAME, "l4a");
        if ( $LDEBUG ne "" ) { print "l4a $msheet -> $BASENAME\n"; }
    }
    # check to see if we've been asked to stop
    if ( -f "/tmp/linksheets.stop.$MODE" ||
         -f "/tmp/linksheets.stop" ) {
        set_power_led('blink off');
        set_power_led('on');
        system("logger -t linksheets \"linksheets.stop found, exiting immediately!!!\"");
        exit 3;
    }
}

# now process any soft links, anything that gets
# logged indicates that the given folder does not
# have a properly named sheet
foreach my $DIRNAME (keys(%soft_links)) {
    if ( ! -e $DIRNAME ) {
   my $msheet = $soft_links{$DIRNAME};
        symlink($msheet, $DIRNAME);
   if ( $LDEBUG ne "" ) { print "l5  $msheet -> $DIRNAME\n"; }
    }
}

set_power_led('blink off');
set_power_led('on');
system("logger -t linksheets \"Done MovieSheets for " . $ARGV[0] . ", mode " . $ARGV[1] . "\"");
sdotech01
Donor
 
Posts: 54
Joined: Tue Jun 14, 2011 11:58 am

Re: LINKSHEETS for IDIOTS   

Postby KAD » Fri Oct 05, 2012 3:15 pm

Code: Select all
#!/bin/sh  <-- shebag tells the system what interpreter to use
chmod a+x /conf/linksheets.pl    <---fix permissions
mount --bind /conf/linksheets.pl /usr/bin/linksheets  <-- tell the system any request to run linksheets, use /conf/linksheets.pl instead of the bash script


once the mount --bind cmd is done, you don't need to /conf/linksheets.pl
you can just type linksheets and it will run the perl version of the script

not sure which other lines your using

Code: Select all
(sleep 30 && /path/to/linksheets.pl /tmp/media/usb) &  <-- tell the system to open a separate sub shell and run the script
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: LINKSHEETS for IDIOTS   

Postby sdotech01 » Fri Oct 05, 2012 3:34 pm

KAD wrote:
Code: Select all
#!/bin/sh  <-- shebag tells the system what interpreter to use
chmod a+x /conf/linksheets.pl    <---fix permissions
mount --bind /conf/linksheets.pl /usr/bin/linksheets  <-- tell the system any request to run linksheets, use /conf/linksheets.pl instead of the bash script


once the mount --bind cmd is done, you don't need to /conf/linksheets.pl
you can just type linksheets and it will run the perl version of the script

not sure which other lines your using

Code: Select all
(sleep 30 && /path/to/linksheets.pl /tmp/media/usb) &  <-- tell the system to open a separate sub shell and run the script


this is exactly what is in my S99user-script
Code: Select all
#!/bin/sh
chmod a+x /conf/linksheets.pl
/conf/linksheets.pl /tmp/mnt/EEE0B450E0B420AF
/conf/linksheets.pl /tmp/mnt/01CD17DD70F15D90
mount --bind /conf/linksheets.pl /usr/bin/linksheets


it's just weird that even giving it the locations to scan it gives me sheets to a different location that existed then didn't. it's like it's scanning at startup and seeing a folder briefly and then it dissapears adn then it begins to scan again after but once the link is there it doesn't overwrite it with a correct one.
sdotech01
Donor
 
Posts: 54
Joined: Tue Jun 14, 2011 11:58 am

PreviousNext

Return to Movie Sheet Support & Discussion

Who is online

Users browsing this forum: No registered users and 3 guests