Solved Get Ember to work in sabnzbd, how?
#16
Ya. Didn't think so

Xbmc control i believe

[quote='bry-' pid='1455798' dateline='1372842967']
Ya. Didn't think so. Was worth a shot :-) ty
Reply
#17
(2013-07-03, 01:14)Steveb Wrote: The command line you posted earlier works, just remember that the -newauto is for movies not existing in embers db so for this to work do not enter ember and perform update library, if you have added movies to embers db but not scraped info/art use the -missauto -all command. Here is a copy of the bat file I use.

Code:
start "" "D:\Ember\Ember Media Manager.exe" -newauto -all -nowindow

REM Command lines
REM -------------
REM -fullask
REM -fullauto
REM -missask
REM -missauto
REM -newask
REM -newauto
REM -markask
REM -markauto
REM -file
REM -folder
REM -export
REM -template
REM -resize
REM -all
REM -nfo
REM -posters
REM -fanart
REM -extra
REM -nowindow
REM -run

Thanks so much! Indeed it does work. Your explanation on how it works revelaed my problem. I was simply (and stupidly) deleting the nfo and artwork files for a couple movies expecting it to re-scrape them. But since they were already in the Ember db, -newauto wouldn't re-scrape them. I've tried deleting a few from the Ember db and now the command line scrapes them. So helpful.
Reply
#18
Sorry rockdawg I wasn't subscribed to this thread... Catching up now I see you got your info... Hopefully its working for u...
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#19
Hey,

I've adapted Steveb's script to run with Python like this:

Code:
def run_ember():

    ###########################################
    #### Ember Media Manager Auto Scraping ####
    ###########################################
    ### Command lines
    ### -------------
    ### -fullask
    ### -fullauto
    ### -missask
    ### -missauto
    ### -newask
    ### -newauto
    ### -markask
    ### -markauto
    ### -file
    ### -folder
    ### -export
    ### -template
    ### -resize
    ### -all
    ### -nfo
    ### -posters
    ### -fanart
    ### -extra
    ### -nowindow
    ### -run
    ###########################################

    # Lauch Ember Media Manager and store PID for future kill
    #subprocess.Popen('"D:\EmberMM\Ember Media Manager.exe" -newauto -all -nowindow')
    sp = subprocess.Popen('"D:\EmberMM\Ember Media Manager.exe" -newauto -all -nowindow')
    pid = str(sp.pid)
    Logger.info('- Ember Media Manager: running on PID: (' + pid + ')' )
    time.sleep(300)
    # Kill Lauch Media Manager's PID
    #subprocess.Popen('taskkill /IM "Ember Media Manager.exe" /F')
    subprocess.Popen("taskkill /F /T /PID %i"%sp.pid)    
    Logger.info('- Killed Ember Media Manager on PID: (' + pid + ')' )

If I run it manually it runs as supposed to (it opens Ember's splash screen but no window)

If I run it as a procedure in SABnzbd's post processing script I can see Ember Media Manager.exe program running but nothing gets scrapped. The script ends successfully but it doesn't get what is supposed to.

Can anyone help me with this?

this method is running like this in my nzbToCouchpotato:
Code:
if result == 0:
    # Logger.info("Checking SABnzbd status...")
    # autoProcessMovie.check_sabnzbd()
    # Run Ember Media Manager to scrapre additional data
    Logger.info("Launching Ember Media Manager to scrape additional data...")
    autoProcessMovie.run_ember()
    # Update XBMC Video Library
    Logger.info("Update XBMC Video Library...")
    autoProcessMovie.update_library()
    # SUCCESS: autoProcessMovie script ran successfully!
    Logger.info("The autoProcessMovie script completed successfully.")

result == 0 comes from the couchpotatoserver's response.

Thanks
Image Image
Reply
#20
(2013-07-11, 16:22)redglory Wrote: Hey,

I've adapted Steveb's script to run with Python like this:

Code:
def run_ember():

    ###########################################
    #### Ember Media Manager Auto Scraping ####
    ###########################################
    ### Command lines
    ### -------------
    ### -fullask
    ### -fullauto
    ### -missask
    ### -missauto
    ### -newask
    ### -newauto
    ### -markask
    ### -markauto
    ### -file
    ### -folder
    ### -export
    ### -template
    ### -resize
    ### -all
    ### -nfo
    ### -posters
    ### -fanart
    ### -extra
    ### -nowindow
    ### -run
    ###########################################

    # Lauch Ember Media Manager and store PID for future kill
    #subprocess.Popen('"D:\EmberMM\Ember Media Manager.exe" -newauto -all -nowindow')
    sp = subprocess.Popen('"D:\EmberMM\Ember Media Manager.exe" -newauto -all -nowindow')
    pid = str(sp.pid)
    Logger.info('- Ember Media Manager: running on PID: (' + pid + ')' )
    time.sleep(300)
    # Kill Lauch Media Manager's PID
    #subprocess.Popen('taskkill /IM "Ember Media Manager.exe" /F')
    subprocess.Popen("taskkill /F /T /PID %i"%sp.pid)    
    Logger.info('- Killed Ember Media Manager on PID: (' + pid + ')' )

If I run it manually it runs as supposed to (it opens Ember's splash screen but no window)

If I run it as a procedure in SABnzbd's post processing script I can see Ember Media Manager.exe program running but nothing gets scrapped. The script ends successfully but it doesn't get what is supposed to.

Can anyone help me with this?

this method is running like this in my nzbToCouchpotato:
Code:
if result == 0:
    # Logger.info("Checking SABnzbd status...")
    # autoProcessMovie.check_sabnzbd()
    # Run Ember Media Manager to scrapre additional data
    Logger.info("Launching Ember Media Manager to scrape additional data...")
    autoProcessMovie.run_ember()
    # Update XBMC Video Library
    Logger.info("Update XBMC Video Library...")
    autoProcessMovie.update_library()
    # SUCCESS: autoProcessMovie script ran successfully!
    Logger.info("The autoProcessMovie script completed successfully.")

result == 0 comes from the couchpotatoserver's response.

Thanks

Interested in your script... can you post it when completed, or if you need help?
right now I use eventghost and batch scripts to handle ember... kinda clunkie!
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#21
I have made an bat and exe file with the same problem, which I why I have created the thread here and also on Sabnzbd forum, but no one seems to have the key to solve the problem. Ember is launched since I can see it in processes in task manager but nothing happens..

And Lunatixz can you get a bat file to work in sabnzbd to scrape in Ember?
Reply
#22
My setup has sabnzb run couchpotatos post script... but I added eventghost triggers to the script... when the "movie moved" trigger is tripped, eventghost launches ember batch.
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#23
I know we can override this script problem with additional ones like eventghost but I would like to find the problem for future reference. Smile

Thanks nevertheless, btw.
Image Image
Reply
#24
(2013-07-12, 19:03)redglory Wrote: I know we can override this script problem with additional ones like eventghost but I would like to find the problem for future reference. :)

Thanks nevertheless, btw.

I agree I'm just answering bjur... I would like a more direct fix...
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#25
(2013-07-12, 19:03)redglory Wrote: I know we can override this script problem with additional ones like eventghost but I would like to find the problem for future reference. Smile

Thanks nevertheless, btw.

I read this thread and from what I understand if you run the script directly/manually than Ember works but if you let SABN/Couchpototo run the script Ember doesn't work? Maybe try using admin privilegies, this sounds indeed odd.
Reply
#26
Tried to open notepad.exe instead of Ember and same result... Process gets started and no notepad...

autoProcessMovie.py waits for notepad to close (returncode) so that it finishes its job.

I went to see how SABnzbd builds script command/arguments:

1st thing inside https://github.com/sabnzbd/sabnzbd/blob/...sunpack.py

Code:
if sabnzbd.WIN32:
    try:
        import win32api
        from win32con import SW_HIDE
        from win32process import STARTF_USESHOWWINDOW, IDLE_PRIORITY_CLASS
    except ImportError:
        pass
else:
    # Define dummy WindowsError for non-Windows
    class WindowsError(Exception):
        def __init__(self, value):
            self.parameter = value
        def __str__(self):
            return repr(self.parameter)

As stated, external scripts get called from:
Code:
def external_processing(extern_proc, complete_dir, filename, msgid, nicename, cat, group, status):
    """ Run a user postproc script, return console output and exit value
    """
    command = [str(extern_proc), str(complete_dir), str(filename),
               str(nicename), str(msgid), str(cat), str(group), str(status)]

    if extern_proc.endswith('.py') and (sabnzbd.WIN32 or not os.access(extern_proc, os.X_OK)):
        command.insert(0, 'python')
    stup, need_shell, command, creationflags = [b][u]build_command(command)[/u][/b]
    env = fix_env()

    logging.info('Running external script %s(%s, %s, %s, %s, %s, %s, %s)',
                 extern_proc, complete_dir, filename, nicename, msgid, cat, group, status)

    try:
        p = subprocess.Popen(command, shell=need_shell, stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
                            startupinfo=stup, env=env, creationflags=creationflags)
    except:
        logging.debug("Failed script %s, Traceback: ", extern_proc, exc_info = True)
        return "Cannot run script %s\r\n" % extern_proc, -1

    output = p.stdout.read()
    ret = p.wait()
    return output, ret

#------------------------------------------------------------------------------

And these parameters get populated inside "build_command" function:
Code:
def build_command(command):
    """ Prepare list from running an external program
    """
    if not sabnzbd.WIN32:
        if IONICE_COMMAND and cfg.ionice().strip():
            lst = cfg.ionice().split()
            lst.reverse()
            for arg in lst:
                command.insert(0, arg)
            command.insert(0, IONICE_COMMAND)
        if NICE_COMMAND and cfg.nice().strip():
            lst = cfg.nice().split()
            lst.reverse()
            for arg in lst:
                command.insert(0, arg)
            command.insert(0, NICE_COMMAND)
        need_shell = False
        stup = None
        creationflags = 0

    else:
        [b]need_shell = os.path.splitext(command[0])[1].lower() not in ('.exe', '.com')
        stup = subprocess.STARTUPINFO()
        stup.dwFlags = STARTF_USESHOWWINDOW
        stup.wShowWindow = SW_HIDE
        creationflags = IDLE_PRIORITY_CLASS[/b]

        # Work-around for bug in Python's Popen function,
        # scripts with spaces in the path don't work.
        if need_shell and ' ' in command[0]:
            command[0] = win32api.GetShortPathName(command[0])
        if need_shell:
            command = list2cmdline(command)

    return stup, need_shell, command, creationflags

If I understand correctly, in my case I get:
stup = subprocess.STARTUPINFO() - Populate handle with default structure parameters.
Info for STARTUPINFO structure
Code:
Specifies the window station, desktop, standard handles, and appearance of the main window for a process at creation time.

stup.dwFlags = STARTF_USESHOWWINDOW
Code:
STARTF_USESHOWWINDOW
0x00000001
The wShowWindow member contains additional information.
stup.wShowWindow = SW_HIDE
Code:
wShowWindow
If dwFlags specifies STARTF_USESHOWWINDOW, this member can be any of the values that can be specified in the nCmdShow parameter for the ShowWindow function, except for SW_SHOWDEFAULT. Otherwise, this member is ignored.
For GUI processes, the first time ShowWindow is called, its nCmdShow parameter is ignored wShowWindow specifies the default value. In subsequent calls to ShowWindow, the wShowWindow member is used if the nCmdShow parameter of ShowWindow is set to SW_SHOWDEFAULT.

So I suppose this parameter prevents cmd window opening after running command?!

need_shell = True ('cause my script doesn't end in '.exe' or '.com'.) - default shell 'cmd' i suppose Smile

creationflags = IDLE_PRIORITY_CLASS
Code:
Processes that monitor the system, such as screen savers or applications that periodically update a display, should use IDLE_PRIORITY_CLASS. This prevents the threads of this process, which do not have high priority, from interfering with higher priority threads.

command = 'python nzbToCouchPotato.py [complete_dir] [filename] [nicename] [msgid] 'movies' [group] [status]'
Code:
command = [str(extern_proc), str(complete_dir), str(filename),
               str(nicename), str(msgid), str(cat), str(group), str(status)]

Is the problem related to stup.wShowWindow = SW_HIDE ? I suppose the shell window influences how windows apps get opened?

Get crazy with this. Might have to change to NZBGet Big Grin

Thanks for your help!
Image Image
Reply
#27
I think i might have found the problem.

Refering to this property (UserInteractive) it indicates that:

Code:
Property Value
Type: System.Boolean
true if the current process is running in user-interactive mode; otherwise, false.
Remarks
When the UserInteractive property is false, do not display any modal dialogs or message boxes, as there is no graphical user interface for the user to interact with.
[b]This property is false only when called from a [u]service process[/u] or from a Web application.[/b]

So, as Ember opens with a splash screen, if we can omit this it might work. Going to investigate this. Smile
Image Image
Reply
#28
Looking forward to a solutionWink Sorry I can't help since my programming skills is not that impressiveSmile
Reply
#29
(2013-07-15, 00:08)redglory Wrote: I think i might have found the problem.

Refering to this property (UserInteractive) it indicates that:

Code:
Property Value
Type: System.Boolean
true if the current process is running in user-interactive mode; otherwise, false.
Remarks
When the UserInteractive property is false, do not display any modal dialogs or message boxes, as there is no graphical user interface for the user to interact with.
[b]This property is false only when called from a [u]service process[/u] or from a Web application.[/b]

So, as Ember opens with a splash screen, if we can omit this it might work. Going to investigate this. Smile

nice found - thanks for looking into this! I read your previous posting too, but right now I'm in the proces of moving my complete Media Storage from my old NAS to new server, so right now I'm quite busy Smile Hoewever you seem to be on the right track Nod
Reply
#30
It seems Ember never scrapes any TV shows from the command line. It works with movies, but I have yet to see a TV episode scraped after about 20 trys. Is this a known limitation and, if so, can we get it fixed?
Reply

Logout Mark Read Team Forum Stats Members Help
Get Ember to work in sabnzbd, how?1