Results 1 to 5 of 5

Thread: make NFO where its missing from files

  1. #1
    Join Date
    Sep 2020
    Beans
    2

    make NFO where its missing from files

    Hello,

    im new to all this. So hope someone can help me clear the issue.

    i have some movies where nfo is missing. and i would like mediainfo to make a nfo file in the same directory if possible. i have a piece of code, that make a default nfo but no info about the video itself i i don't know how to make it

    but if i read this correct it should go under the else statement?
    and the issue is also that : /xxx/xxx/category can change.
    Code:
    defaultnfo="/home/xxxx/default.nfo"
    i know it's ugly as hell
    Code:
    # set nfo files if [[ $(find ${incoming} -maxdepth 1 -iname \*.nfo | wc -l ) -gt 0 ]]; then
            nfo=$(echo $(find ${incoming} -maxdepth 1 -iname \*.nfo))
            echo NFO Exists $(basename "${nfo}") | tee -a log.txt
            timestamp=$(date +%s)
            cp "${nfo}" ${timestamp}.nfo
            nfo=" --form nfo=@${timestamp}.nfo"
            echo "${nfo}" | tee -a log.txt
    else
            echo "No NFO found for ${name}" | tee -a log.txt
            nfo=" --form nfo=@${defaultnfo}"
    fi
    This one was a test but i think it's overkill to search all *.mkv
    Code:
    #cd /xxx/xxxx/
     #find -name *.mkv -execdir mediainfo --LogFile={}.nfo {} \;
    Last edited by klapvogn; September 21st, 2020 at 02:04 PM.

  2. #2
    Join Date
    Jun 2018
    Beans
    49

    Re: make NFO where its missing from files

    What is an nfo ?

  3. #3
    Join Date
    Sep 2020
    Beans
    2

    Re: make NFO where its missing from files

    Hello,

    my bad its a txt with info about the movie

  4. #4
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    21,648
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: make NFO where its missing from files

    Perhaps if you describe the final system you are trying to get the data into, rather than this intermediate step which may not be needed at all, we can better help?

    When I looked at creating a filter for NFO files about 10 yrs ago. I considered anything beyond just the basic data to be too complex for the level of effort I was willing to expend. Then I discovered that tools like Kodi will accept a 1-line movie-name.nfo file that just points to the IMDB URL for that movie. Nothing else, just a line like this:
    That is sufficient for the tool to find the information and load it into the Kodi DBMS.
    BTW, that is a fun movie. Not great, but fun.

    Please don't run commands as root when it isn't necessary to the OS. That's a good way to trash a system and make access even harder going forward.

  5. #5
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    21,648
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: make NFO where its missing from files

    A minimal .NFO file should be this:
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <movie>
        <title>28 Weeks Later</title>
    </movie>
    I'd make a script that accepts 2 command line arguments, the directory and the title to be used.
    That script would look like this:
    Code:
    #!/bin/bash
    
    if [ -z "$1" ] ; then
      echo Usage: $0 directory title
      exit 1
    fi
    if [ -z "$2" ] ; then
      echo Usage: $0 directory title 
      exit 1
    fi
    
    OUTFILE="$1/$2.nfo"
    
    echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <movie>' | tee "$OUTFILE"
    echo "    <title>$2</title>
    </movie>
    " | tee -a "$OUTFILE"
    Wouldn't take much to directly convert the directory name into the title, if that is desired. There will be issues with some titles and directory names that have some undesirable characters. The worst characters are ' " ! ? & () {} [] which are all special to bash, so those would need to be escaped as needed. Spaces are a hassle too, but should be handled fine above. In my world, I just don't name any files or directories using those characters. That's easier. "Bill & Ted" becomes "Bill_n_Ted". Since the display of the title comes from a database, not a directory name, that hasn't matter much. Movie directory tools like Kodi and Plex prefer names like this "The Baytown Outlaws (2012)" ---> The_Baytown_Outlaws-2012 in my world mainly to make scripting much easier.

    Anyways, that's what I'd do. If the script got much more complex, I'd change from bash into a real programming language like Perl.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •