blog.humaneguitarist.org

discoveries in digital audio, music notation, and information encoding

Return to the Babette Cave

leave a comment

Years ago, when I lived in Columbia, SC (my hometown), I used to spend my weekends (as I do now) playing guitar, listening to music … and watching films.

My Dad's a film buff, so he got me interested in stuff other than Hollywood/Bollywood movies. And he also had the Facets newsletter/catalog, so I was able to see what was "out there". I watched a lot of Scandinavian films, in no small part because I was really into Norse mythology. Mortal gods always seemed like a cool thing to me.

Anyway, one film I always remember renting but not being able to sit through was Babette's Feast, but I never forgot that I was supposed to have watched it.

Well, thanks to the Criterion Film Collection on Hulu, I recently did.

And I'm glad I waited all those years. I simply wouldn't have been able to take anything away from the film all those years ago, a teenager in South Carolina. What would I have known then about how afraid people are of different customs – especially as represented by one of the sisters renouncing a promising singing career … and even more-so by a dinner menu!

Babette's Feast

Unfortunately, I have to move today so I need to cut this short … but what of this blog post's title?

Well, also recently I saw Return to the Batcave: The Misadventures of Adam and Burt while at a friend's house – a few hours away from Columbia.

Return to the Batcave

You can never go wrong with that old, campy Batman series.

--------------

Related Content:

Written by nitin

May 9th, 2013 at 9:11 am

Posted in film

Tagged with , , ,

HammerFlicks and the Netflix API … in the grave?

leave a comment

Well, I've noticed some of the results from HammerFlicks have seemed a little off lately. So I stumbled upon this in regard to the Netflix API:

The following are the changes we are making to the program, all of which are effective immediately (except where otherwise noted):

  • We will no longer issue new public API developer keys.  All existing keys that are actively calling the API will remain active.
  • We will no longer accept new API affiliates.  There will be no impact to existing and active affiliates.
  • We will no longer offer test environments.  The test tools have been unavailable for a while and we won’t bring them back.
  • We will set the forums in the developer portal to read-only.  We encourage developers to continue their conversations at StackOverflow with the tag “netflixapi”.  The existing forum posts will remain on the site for now in the form of an archive.
  • We will retire the OData catalog, effective on April 8, 2013.

source: Netflix API : Changes to the Public API Program. Retrieved May 09, 2013, from developer.netflix.com/blog/read/Changes_to_the_Public_API_Program

Sounds like it might be time to retire HammerFlicks … or at least issue a disclaimer. What's strange is that I didn't receive an email about these changes, whereas I seemed to have gotten email notification of previous API changes. Oh well, business priorities change and Netflix isn't obligated to give away their data.

--------------

Related Content:

Written by nitin

May 9th, 2013 at 8:41 am

Posted in film,news

Tagged with ,

HammerFlicks and pOAIndexter source codes available

leave a comment

Quickie:

I've made the source code available for HammerFlicks (click on the "Source Code" link) and "pOAIndexter" (scroll down to "pOAIndexter").

The "pOIAndexter" scripts is used to drive the metadata harvesting for NC ECHO.

I seriously doubt anyone else will download/use these, but making them downloadable forces me to do a decent job – I hope – of being organized.

--------------

Related Content:

Written by nitin

March 31st, 2013 at 2:52 pm

Posted in news,scripts

Tagged with , ,

on the brain: audio + ocr/hocr, “did you mean”, and “there are no ebooks”

leave a comment

Lightning talk style 'cause I'm home sick and need to get a few things out there …

Audio + OCR/HOCR

Some time ago I wrote this post on OCR/HOCR and making searchable pages. I recently did some tests with generating audio with Festival and using simple HTML5 audio to ad audio to the page. I only used Festival on the OCR output, but by using the HOCR output it's no big thing to make audio for every line that Tesseract "detects" and incorporate it with SAVS or something.

"Did You Mean?"

Google doesn't seem to offer a "did you mean" API, but you can get around it. Other options might be to use Wikipedia's API or Google's own search suggestion API (i.e. first suggestion). In both links to the API, I've sent it "disese" instead of "disease".

There are no eBooks

In digital, why the hell are we still thinking of "eBOOKS" and "digital AUDIO BOOKS", etc.?

Why can't we just think of them as web applications? And instead of having "ebook reader software" and "audio book software" why can't we just use, say, a Python/PyQT based application that uses Webkit? That's to say, I get that for monetary reasons not everything can be open, but why can't I just download a compiled script that runs Webkit and disallows me from doing things like viewing the source, saving the page, etc.? If the files need to be downloaded they can be saved in password secured ZIP files (which can only be downloaded, say, with a username/password). The Webkit app would be the only thing that could talk to a centralized DB and determine if the user still has rights to view the material, if so the DB could hand the application the password to read the contents into memory from the ZIP file, show them through the browser, etc. without making the contents readable otherwise.

What am I missing here? A lot, I'm sure. But there's got to be a better way and we need to stop thinking of digital as a bits/bytes rendering of the physical world. After all, is this an eBook or a digital audio book? I can, of course, both read and/or hear it.

In early tests, making "eBooks" readable via a Python/Webkit app is working, HTML5 audio is working on my computer but not at work, video on neither. But I *think* based on what I've read that there are some bugs with the PyQT Webkit, so maybe it's just a temp thing.

Either way, why keep inventing new software when a secure browser lets us read, listen, and watch? Adding stuff like bookmarks is a simple matter I'd think of storing data in a centralized DB for that given user account (or even a local SQLite db).

Moreover, will there even be "e-readers" and "mp3 players" in the near future? Won't it all just be a "device" of a given size that just runs a web browser?

--------------

Related Content:

Written by nitin

March 7th, 2013 at 12:11 pm

getting real-time values from imported modules with a Python GUI

leave a comment

Situation: Over a year ago I wrote a Python script to allow one to convert XML citations from Pubmed.gov to a Microsoft spreadsheet.

I know some people are using it here and there, so I wanted to make it better.

The main problem with the old script is it's just sloppy (I knew even less back then than I do now!). It's also a script that wraps everything into one: non-GUI and GUI. If you don't pass command line options, then it launches the GUI, etc. Anyway, that makes the code hard to read for me since it intermixes data parsing with command line option stuff and GUI stuff.

So, for the next version I'm working on, I started with the premise to write it as a Python library so that it can be imported and one can use the function to make a spreadsheet inside another Python script a la:

import pubmed2xl
pubmed2xl.makeSheet("pubmed.xml", "pubmed.xls") #pass input and output (Excel file to be written)

It's also setup to make it easy to use command line options a la:

python pubmed2xl.py pubmed.xml pubmed.xls

The function and command line options also support showing the progress of completion while the spreadsheet is being made. This can be called as such:

pubmed2xl.makeSheet("pubmed.xml", "pubmed.xls", showProgress=True)

or

python pubmed2xl.py pubmed.xml pubmed.xsl --verbose

The problem for me, then, was how to show the progress inside a GUI application. Essentially, I needed the value of a the progress counter "variable" that was created inside a loop and updated each time the loop occurred – i.e. updating the progress counter. But I couldn't figure out how to retrieve the value of the progress counter variable in real time as the loop occurred. And I need it in real time so my GUI could show the progress update to the user – in real time!

I spent way too much time following leads that got me nowhere. I tried threads, running the python script as a sub-process, etc.  but I could never access the variable "progressValue" that equates to the percentage of task completion as citations are getting processed into a spreadsheet.

So, somehow I found my way to realizing that if my original script had a class and my second script added a method to the class then I could get the value of "progressValue" in real time.

Anyway, I've got two scripts below. The "first.py" script emulates a progress calculator by simply counting to 100. The script also has a class, "callback" and a global dictionary "_CALLBACK_DICT" into which I can place key/value pairs for whatever variables I want to retrieve during the loop.

The function "canYouSeeMe()" inside "first.py" also tries to execute the method "_CALLBACK.callback()" during the loop. In other words, if the method's there, run it, otherwise just ignore it.

The second script "second.py" is a little TKinter GUI app. It imports the first module and the instantiated class("_CALLBACK"). It also has a function called "getCallback()" that does what I want: i.e. retrieve the progress count in real time and show it in the GUI in real time. I then I equate "getCallback()" to the "_CALLBACK.callback()" method. So now, when I run the "second.py" script, the loop in "first.py" can give me the data I want to show in "second.py" in real time. Make sense? I hope so because it seems to be working OK.

Here's a screenshot from running "second.py" and below are the scripts themselves. I'd love any feedback on better ways of doing this, by the way.

Tkinter callback example

first.py

##### "first.py"

class callback():
  pass
_CALLBACK = callback()
_CALLBACK_DICT = {}

rangers = range(0, 101, 10)
def canYouSeeMe():
  for ranger in rangers:
    _CALLBACK_DICT["this_ranger"] = str(ranger)
    try:
      _CALLBACK.callback()
    except:
      pass

second.py

##### "second.py"

#import first module
import first
from first import _CALLBACK

#import Tkinter
from Tkinter import *

#create function and add as method to class "_CALLBACK"
def getCallback():
    importedValue = first._CALLBACK_DICT["this_ranger"]
    t.insert(END, importedValue + "%\n")
    if importedValue == "100":
        t.insert(END, "\nDone.")
    t.see(END)
    t.update_idletasks()
_CALLBACK.callback = getCallback #adding method to class

#create GUI buttons
class buttons():
   
    def __init__(self, root):
 
        #make frame/button
        frame = Frame(root)
        frame.pack()
       
        buttonText = "go"
        buttonAction = self.go
        self.makeButton = Button(frame, text=buttonText, command=buttonAction)
        self.makeButton.pack()
       
    #run go()
    def go(self):
      first.canYouSeeMe()

#create GUI
root = Tk()
buttons = buttons(root)
t = Text(root, background="black", foreground="blue")
t.pack()
geo = ("150x250")
root.geometry(geo)
root.mainloop()
--------------

Related Content:

Written by nitin

February 7th, 2013 at 3:00 pm

Posted in scripts

Tagged with , , ,

questionable questions and a lazy way to add command line support to a Python module

leave a comment

Ugh.

I just took this Myers-Brigg questionnaire and I just "love" (sarcasm) some of these questions:

Do you usually get along better with imaginative people, or realistic people?

What? Truly imaginative people have to be "realistic" otherwise they're just spewing out pipe-dreams. People who can think of the new and make it a reality have to have a large degree of realism.
   
In reading for pleasure, do you enjoy odd or original ways of saying things, or like writers to say exactly what they mean?

First of call, I question why the question is making some kind of statement as to writer, not the book or the "message", as the basis for selection.

Secondly, show me a writer who thinks they are saying "exactly" what they mean and I'll show you a "writer" who knows not one thing about interpretation of the self let alone the words of others.

Anyway …

Ok, on to the second thing I wanted to say before I jump in the shower past noon (I'm home … say it with me … sick).

I have a Python module with lots of functions. I want them to be importable in other Python scripts AND callable via the command line.

And I want them all callable via the command line without taking the time to write out command line option support.

:P

For example, in a script with a function "echo" that prints an argument, "add" that adds two integers, and "times" that multiplies two integers, I just want to do this:

$ python cl.py echo('hello world')
hello world

$ python cl.py echo(add(1,2))
3

$ python cl.py echo((add(100, times(2,10))))
120

instead of stuff like this:

$ python cl.py --function=echo arg="hello world"

etc. …

Using the built-in "eval" function and "sys.argv" seems to be working:

#cl.py

def echo(s):
  print s

def add(x, y):
  return x + y

def times(x, y):
  return x * y

def main():
  import sys
  try:
    funks = sys.argv[1:] #user must pass strings in single quotes. 
    funks = " ".join(funks)
    eval(funks)
  except:
    pass

if __name__ == "__main__":
  main()
--------------

Related Content:

Written by nitin

January 31st, 2013 at 12:30 pm

Posted in scripts

Tagged with ,

keyword vs. phrase searching of the Soundboard, a GFA publication

leave a comment

As I mentioned before, last summer I went to the Guitar Foundation of America convention in Charleston.

I also mentioned that I'd asked some questions about whether the GFA journal, "Soundboard" was full-text indexed.

Via the FlippingBook software the GFA uses to display current issues online (membership required), there is full-text searching capability because the content is indexed as far as I can tell. But as I was saying, I don't think one can search across *all* online Soundboards simultaneously – i.e. fire off one query and get results across all online Soundboards. I could be wrong about that.

In contrast, the PDF back issues sold on a DVD-ROM are not full-text indexed nor full-text searchable with Adobe Acrobat Reader as far as I can tell. And I think this is where there's real confusion – perhaps on my part – about what we mean when we use terms like "keyword" searching.

To me, keyword searching means full-text and not a "find" (as in Acrobat Reader). The Webopedia site differentiates these as "keyword" and "phrase" searches, respectively. The GFA is using a different meaning, per the "How to search Soundboard back issues.pdf" file that comes with the DVD, for "keyword" searching:

"These issues have been processed both to reproduce the page-by-page appearance of the originals on your computer screen, and to apply an "optical character recognition" (OCR) process to the text, so that every page of every issue is now keyword searchable."

In my experience, however, the search provided internally via Adobe Acrobat Reader (and Foxit Reader, too) is what I'd just call a "find" (i.e. the same as Ctrl-F on your browser). In fact, in my version of Acrobat Reader and per the screenshot in the "How to search Soundboard back issues.pdf" file, Adobe also uses the phrase "find" and not "search" in their application. Their "Advanced Search" adds options really dealing with what to search (comments, all files in a folder, etc.) but not really how to search (in the algorithmic sense) – so, it's still a "find", though more feature-rich. Now, if you have Acrobat Pro (admittedly I do through work) you apparently can create an index and then actually do a full-text search, but that doesn't help people who don't have the pro version and won't/can't buy it.

Granted, I can index the PDF with my operating system (Windows) and do a full-text search, but I don't really get much useful information other than what files match. I don't get useful information on where the passage exists (page number, etc).

Consider the following passage from Soundboard Volume 1, Number 1, 1974:

"Mr. Llois Mauerhofer, Elizabethstrasse 93, 8010 Graz, Lustria, was reported working on a doctoral dissertation at the University of Graz on Leonard von Call, early 19th c. guitarist active in Vienna who is best remembered for his serenades for guitar and strings."

A "find" won't match that passage if you search for "Graz University" or "University Graz" or "strings Vienna" but a real keyword search likely would.

Of course, a demonstration is in order, so using a tool called Apache Tika to extract the text from the aformentioned PDF scan of Soundboard v.1, #1, 1974; a little Python software script I wrote to output the data to a database-friendly file; and an online database, I indexed the data and made a little API – all that means is that there's page you can go to, throw some search terms at it, and get the results back as structured data (um, usually not fun to read through).

By the way, I normally use more technical jargon in my posts but I have some guitarist buddies who I want to read this page.

Anyway, here are the three searches mentioned above that don't yield results in Acrobat Reader but do using a full-text search (you can see the search terms in bold in the links below). Don't worry if you can't read the output, just focus on the fact that something comes back (provided my database isn't down at the moment!).

http://blog.humaneguitarist.org/uploads/Soundboard/currentVersion/search/?q=Graz+University
http://blog.humaneguitarist.org/uploads/Soundboard/currentVersion/search/?q=University+Graz
http://blog.humaneguitarist.org/uploads/Soundboard/currentVersion/search/?q=strings+Vienna

For a more user-friendly version, try going here:

http://blog.humaneguitarist.org/uploads/Soundboard/currentVersion/soundboard_search.html

Try typing in the three searches mentioned above. Then try some more searches for fun. For simplicity's sake, I hard-coded the system to never return more than 10 results.

Of course, this should all scale to indexing the text of all the PDFs on the DVD, but exposing those openly on the web wouldn't be appropriate.

But my point with this demo is to say that this is more like what I meant by "keyword" searching at the GFA convention. There's probably a way to ingest the old PDFs into the FlippingBook software or at least something else like the Internet Archive book reader. That would probably require re-OCRing the images so that the coordinates of the words could be indexed as well, allowing one to see where on a page the results are, just as with the current issues via FlippingBook.

Ok, if you're still here and are a geek, here's the Python script, "soundboardToTabDelimited.py".

'''
usage example:
  $ python soundboardToTabDelimited.py V01-n1-1974.pdf

This yields "V01-n1-1974.xhtml" and then "V01-n1-1974.txt"
 
Note: you must have the lxml module installed (which isn't always fun).
You can get it here: http://lxml.de/
'''

import codecs, subprocess, sys
from lxml import etree

##### globals
tab = "\t"
br = "\n"


##### run Apache Tika on the file passed via the command line
soundboard = sys.argv[1].replace(".pdf", "")
command_string = "java -jar tika-app-1.2.jar %s > %s" %(soundboard + ".pdf", soundboard + ".xhtml")
command = subprocess.Popen(command_string, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
command.wait() #wait until the subprocess finishes.


##### write file headers (this needs to be deleted if you're going to later import the file via PHPMyAdmin).
tab_delimited = codecs.open(soundboard + ".txt", "w", "utf-8") #output file

tab_delimited.write("journal_id" + tab + "volume" + tab + \
                    "issue" + tab + "year" + tab + \
                    "page_id" + tab + "text_id" + tab + "text" + br)


##### extract volume, issue, year from filename
volume = int(soundboard.split("-")[0].replace("V", ""))
issue = int(soundboard.split("-")[1].replace("n", ""))
year = int(soundboard.split("-")[2])
journal_id = "%04d_%04d_%04d" %(volume, issue, year)


##### parse xhtml file
soundboard_parse = etree.parse(soundboard + ".xhtml")
root = soundboard_parse.xpath(".")

div_tags = root[0].xpath("//xhtml:div[@class='page']",
             namespaces={"xhtml":"http://www.w3.org/1999/xhtml"})


##### extract text from each div/p tag and write data to file
page_id = 1
for div_tag in div_tags:
  text_id = 0
  p_tags = div_tag.xpath("xhtml:p",
             namespaces={"xhtml":"http://www.w3.org/1999/xhtml"})

  for p_tag in p_tags:
    p_text = p_tag.text
    if p_text !=None and p_text !="":
      p_text = p_text.replace(br, "")
      p_text = p_text.replace(tab, "  ")
      p_text = p_text.strip()
      if p_text != "":
        tab_delimited.write(str(journal_id) + tab + str(volume) + tab + \
                            str(issue) + tab + str(year) + tab + \
                            str(page_id) + tab + str(text_id) + \
                            tab + p_text + br)
        text_id = text_id + 1
     
  page_id = page_id + 1

tab_delimited.close()
# fin
--------------

Related Content:

Written by nitin

January 5th, 2013 at 12:35 pm

Cinderella’s Seventh Seal: The Phantom Carriage

leave a comment

Happy New Year.

Speaking of New Year's, I avoided "amateur night" as one of my favorite bartenders called it.

Instead of going out, I stayed home and watched "The Phantom Carriage" on Hulu. The arrival of the New Year plays an important part in the film.

Phantom Carriage poster

Earlier this week, I watched another silent film, "The Unknown" with Lon Chaney. It's kind of like a one-way, gruesomely macabre spin on "The Gift of the Magi".

It's been a few years since I watched some silents at home, but in large part my interest has been renewed by reading "American Silent Film" by William K. Everson.

--------------

Related Content:

Written by nitin

January 1st, 2013 at 2:01 pm

PyEDS: a simple Python starter library for Ebsco’s Discovery Service (EDS)

leave a comment

Before this little vacation I'm on started (sadly, it's almost over!), I was allowed to have access to Ebsco's Discovery Service (EDS) API and its documentation WIKI.

I sent a tiny bit of feedback on some of the things in the documentation that I think are unclear or really need correction and I'm looking to send more when I return to work.

My biggest concern was that  – and I think this is true of A LOT of API documentation – it requires a lot of reading on the user's part to figure out what means what, which almost invariably exceeds the amount of work to actually write the code to authenticate, make queries, etc.

That's to say that often working through documentation about tying a shoelace is more of a task than actually tying said shoelace.

I *think* developers really just want to start experimenting with code, so clarity and really concise language with examples are really of the utmost importance.

Speaking of examples, I also think that sample code needs to have scope in mind. What I'm getting at is that sample code for a search API shouldn't be a "soup to nuts" thing that entails authenticating, making requests, having a client-side UI/interface and displaying results, etc. That's too much. Again, I think (off the top of my head of course and with nothing more than a gut feeling) that it might be more helpful to simply show how to authenticate and make a request and show the formatting of a sample response. The other stuff – interface, UI, etc, etc. – just convolutes the code and adds noise to the basics. In fact, that confuses API usage implementation vs. the API usage itself.

Better still would be to offer small libraries in popular scripting languages that simplify the basics – again, to facilitate people playing with one's API's. The easier and more "fun" it is, the more likely I think (yeah, yeah, I know!) people are likely to really dream about incorporating the API, etc. into their applications and what-nots.

So along those lines, I've pasted a little sample Python script below that makes it really easier for me to authenticate, open a session, conduct searches, format the JSON response, and close the session. It needs work (what doesn't?) but it does what I mean for it to for now.

I probably shouldn't post a sample response since access to the EDS WIKI is for customers only, but if you aren't a customer or at least aren't interested, why are you even reading this?

:P

#PyEDS.py

'''
This module provides a basic Python binding to Ebsco's EDS API, allowing one to:
  - authenticate with a UserID and Password,
  - open and close a session,
  - perform a search (results are returned as JSON),
  - pretty print the JSON.
 
Thanks,
Nitin Arora; nitaro74@gmail.com
____________________________________________________________________________________________________
#Usage example:
 
  import PyEDS as eds
  
  eds.authenticateUser('USERID_GOES_HERE', 'PASSWORD_GOES_HERE')
  eds.openSession('PROFILE_GOES_HERE', 'GUEST_GOES_HERE', 'ORG_GOES_HERE')
 
  #eds.authenticateFile() #alternative to using authenticateUser() and openSession()
  #uses values in JSON config file argument(default="config.json")
  
  #sample "config.json" file:
  """
  {
    "EDS_config": {
      "UserId": "USERID_GOES_HERE",
      "Password": "PASSWORD_GOES_HERE",
      "Profile": "PROFILE_GOES_HERE",
      "Guest": "GUEST_GOES_HERE",
      "Org": ORG_GOES_HERE
    }
  }
  """
 
  kittens = eds.advancedSearch('{"SearchCriteria":{"Queries":[{"Term":"kittens"}],"SearchMode":"smart","IncludeFacets":"y","Sort":"relevance"},"RetrievalCriteria":{"View":"brief","ResultsPerPage":10,"PageNumber":1,"Highlight":"y"},"Actions":null}')
  puppies = eds.advancedSearch('{"SearchCriteria":{"Queries":[{"Term":"puppies"}],"SearchMode":"smart","IncludeFacets":"y","Sort":"relevance"},"RetrievalCriteria":{"View":"brief","ResultsPerPage":10,"PageNumber":1,"Highlight":"y"},"Actions":null}')
  cubs = eds.basicSearch('cubs')
  piglets = eds.basicSearch('piglets', view='brief', offset=1, limit=10, order='relevance')
  
  eds.closeSession()
  
  print 'Some search results with the EDS API ...'
  print '\n"kittens" advanced search as original JSON:'
  print kittens
  print '\n"puppies" advanced search as original JSON:'
  print puppies
  print '\n"kittens" advanced search as JSON with indentation and non-ascii escaping:'
  print eds.prettyPrint(kittens)
  print '\n"cubs" and "piglets" basic searches as original JSON:'
  print cubs, piglets
  print '\nGoodbye.'
____________________________________________________________________________________________________
 
TO DO:
  - add more options to basicSearch() like "facets", "search mode", "fulltext", "thesauras", etc.
    - can't hurt! :-]
  - consider adding an authenticateIP() function that uses the IP authentication method.
  - deal with expired tokens, etc.; see: http://edswiki.ebscohost.com/API_Reference_Guide:_Appendix
'''
 
import urllib2
_EDS_ = {}
 
 
def authenticateUser(UserId, Password):
  '''Authenticates user with an EDS UserId and Password.'''
  auth_json = '{"UserId":"%s","Password":"%s","InterfaceId":"WSapi"}' %(UserId, Password)
  req = urllib2.Request(url='https://eds-api.ebscohost.com/authservice/rest/UIDAuth',
                        data=auth_json,
                        headers={'Content-Type':'application/json'})
  req_open = urllib2.urlopen(req)
  req_results = req_open.read()
  
  req_results_dictionary = eval(req_results) #convert JSON to dictionary.
  _EDS_['AuthToken'] = req_results_dictionary['AuthToken']
  _EDS_['AuthTimeout'] = req_results_dictionary['AuthTimeout']
 
 
def openSession(Profile, Guest, Org):
  '''Opens the EDS session with an EDS Profile, the Guest value ("y" or "n"), and the Org nickname.'''
  sessionOpen_json = '{"Profile":"%s","Guest":"%s","Org":"%s"}' %(Profile, Guest, Org)
  req = urllib2.Request(url='http://eds-api.ebscohost.com/edsapi/rest/CreateSession',
                        data=sessionOpen_json,
                        headers={'Content-Type':'application/json',
                        'x-authenticationToken':_EDS_['AuthToken']})
  req_open = urllib2.urlopen(req)
  req_results = req_open.read()
 
  req_results_dictionary = eval(req_results)
  _EDS_['SessionToken'] = req_results_dictionary['SessionToken'].replace('\\/', '/')
 
 
def closeSession():
  '''Closes the EDS sesssion.'''
  sessionClose_json = '{"SessionToken":"%s"}' %(_EDS_['SessionToken'])
  req = urllib2.Request(url='http://eds-api.ebscohost.com//edsapi/rest/EndSession',
                        data=sessionClose_json,
                        headers={'Content-Type':'application/json',
                        'x-authenticationToken':_EDS_['AuthToken']})
  urllib2.urlopen(req)
  
  
def authenticateFile(config_file='config.json'):
  '''Uses values in JSON config file to authenticate *and* open a session.'''
  config = open(config_file, 'r').read()
  config = eval(config)
  config = config['EDS_config']
  authenticateUser(config['UserId'], config['Password'])
  openSession(config['Profile'], config['Guest'], config['Org'])
 
 
def basicSearch(query, view='brief', offset=1, limit=10, order='relevance'):
  '''Returns search results using basic arguments.'''
  search_json = '''{"SearchCriteria":{"Queries":[{"Term":"%s"}],"SearchMode":"smart","IncludeFacets":"n","Sort":"%s"},
                   "RetrievalCriteria":{"View":"%s","ResultsPerPage":%d,"PageNumber":%d,"Highlight":"n"},"Actions":null}
                   ''' %(query, order, view, limit, offset)
  return advancedSearch(search_json)
 
         
def advancedSearch(search_json):
  '''Returns search results using the full EDS search syntax (JSON).'''
  req = urllib2.Request(url='http://eds-api.ebscohost.com/edsapi/rest/Search',
                        data=search_json, headers={'Content-Type':'application/json',
                        'x-authenticationToken':_EDS_['AuthToken'],
                        'x-sessionToken':_EDS_['SessionToken']})
  req_open = urllib2.urlopen(req)
  req_results = req_open.read()
  return req_results
 
 
def prettyPrint(json_string):
  '''Returns a pretty-printed, UTF-8 encoded JSON string with escaped non-ASCII characters.'''
  import json
  dictionary = json.loads(json_string, encoding='utf=8')
  return json.dumps(dictionary, ensure_ascii=True, indent=2, encoding='utf-8')
 
 
#fin
--------------

Related Content:

Written by nitin

December 30th, 2012 at 11:23 am

Rock Me Milos Forman

leave a comment

I'm enjoying (sort of) a little vacation given that the institution I work at is closed for the holidays. I have a lot of composition stuff I'm working on these days which equates to some exhausting mornings and a lack of practicing the pieces I'm working on.

Anyway, I've been meaning to write a little post for some time on one of my all time favorite films, and arguably the film that most changed the direction of my life, Milos Forman's "Amadeus".

Amadeus movie poster

This movie is one of three I credit with having an enormous influence on my life, the other two being "Star Wars" (yes, I call it "Star Wars" not a "New Hope") and "Sholay". The former probably did more to instill a perhaps naive and childish optimism in me, the latter – almost to the contrary – taught me that doing the right thing is often not glorious, but painful.

But "Amadeus" is the reason I got into Music more than anything. It also is likely the first film that made me aware of film as an art and not this mystical audio-visual experience that "Star Wars" and "Sholay" were for me, given that I was much younger when I first watched those. There was so much talk about F. Murray Abraham's and Tom Hulce's performances, that I couldn't *not* be made aware of it as a cinematic product.

For all three films, I estimate I've easily seen "Star Wars" over 100 times, and I've probably seen "Sholay" and "Amadeus" at least 50 times each. I could still watch "Star Wars" with relative ease but watching "Sholay", given the ending, is a bit of trying experience, most especially during the song "Yeh Dosti" which foreshadows the tragic ending of the film; but if I wanted to watch it again I could do it.

In contrast, I recently tried to watch "Amadeus". I just couldn't. And perhaps I don't need to anymore.

I think the biggest factor was that I had the director's cut and all the extra scenes were really jarring to me, it was like discovering an undesirable dimension to a person I thought I knew well. It's somewhat like how Music has changed for me, too. It's no longer a mystery, it's work, work that I enjoy most of the time.

Anyway, there's a good comparison between the theatrical/director's versions here (warning: there might be some movie poster images on the website that you might not want to see).

In large part, I think the theatrical version is far better. The director's cut has … how does one say? … "too many notes".

The only thing I really found interesting about the extra scenes was how much food played a part in Salieri's life, as if his denial of other worldly pleasures had led him to gluttony. But F. Murray Abraham is too thin for that to work and also by hiding some details about his flaws and his conniving as in the theatrical version, I think he more effectively comes across (in the theatrical version) as a symbol of jealousy and the rightful patron saint of mediocrity.

    Written by nitin

    December 27th, 2012 at 3:44 pm

    Switch to our mobile site