Package jazzparser :: Package utils :: Module web
[hide private]
[frames] | no frames]

Module web

source code


Author: Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>

Classes [hide private]
  ChordSequenceParseError
Functions [hide private]
 
find_midi_files(name, sources=None, verbose_out=None)
Given the name of a piece of music, tries to retrieve MIDI files for a piece of that name.
source code
 
remove_duplicate_files(files, key=<function <lambda> at 0x3d51848>)
Given a list of file data strings, removes any duplicates of the same data.
source code
 
the_jazz_page_midi_files(name, refresh_cache=False, verbose_out=None)
The Jazz Page has quite a few of midi files on a single page.
source code
 
refresh_the_jazz_page_cache()
Reads entries from The Jazz Page into a local cache for searching.
source code
 
van_basco_midi_files(name, verbose_out=None)
One method of getting midi files used by find_midi_files.
source code
 
intersearch_midi_files(name, verbose_out=None)
One method of getting midi files used by find_midi_files.
source code
 
melody_catcher_midi_files(name, verbose_out=None)
One method of getting midi files used by find_midi_files.
source code
 
get_linked_file(page_url, filename, timeout=3)
Often the links on search results pages for MIDI files will be to a page that references the file, rather than to the file itself.
source code
 
get_vanilla_book()
Downloads the whole of the Vanilla Book: L{http://www.ralphpatt.com/Song.html}.
source code
 
get_irealb(url, skip=0)
Get the iReal b format chord sequences from a webpage.
source code
Variables [hide private]
  SOURCES = ['jazzpage', 'vanbasco', 'intersearch', 'melodycatch...
  __package__ = None
hash(x)
Function Details [hide private]

find_midi_files(name, sources=None, verbose_out=None)

source code 

Given the name of a piece of music, tries to retrieve MIDI files for a piece of that name.

Looks up the name on vanBasco's midi search and tries to parse the results to pull the file urls out. Most of these will fail, either because the midi file isn't accessible at the obviously place, or because the link's out of date (many are).

name may be a unicode string.

Parameters:
  • sources (list of strings) - list of source names to get files from. Possibilities are in SOURCES. If None, uses all sources.
  • verbose_out (writable file-like object) - stream to send verbose output to (default None - no verbose output)
Returns:
list of (midi-file,song-name) pairs each containing a midi.EventStream for each file.

remove_duplicate_files(files, key=<function <lambda> at 0x3d51848>)

source code 

Given a list of file data strings, removes any duplicates of the same data. Only the first occurence of the file data will be kept.

The list doesn't have to be just of the data, as long as the data is returned by the key function applied to each value in the list.

the_jazz_page_midi_files(name, refresh_cache=False, verbose_out=None)

source code 

The Jazz Page has quite a few of midi files on a single page. There's only one of most songs and it's not exactly a huge database, but they claim to be high quality.

By default, the list of midi files and song names will be cached the first time it's fetched. Subsequently, songs will just be looked up in the local database. Use refresh_cache=True to force the list to be re-read from the site.

To refresh the cache without doing a search, see refresh_the_jazz_page_cache.

Returns:
list of (midi-file,song-name) pairs each containing a midi.EventStream for each file. Unlikely to be more than one.

refresh_the_jazz_page_cache()

source code 

Reads entries from The Jazz Page into a local cache for searching.

van_basco_midi_files(name, verbose_out=None)

source code 

One method of getting midi files used by find_midi_files.

Looks up the name on vanBasco's midi search and tries to parse the results to pull the file urls out. Most of these will fail, either because the midi file isn't accessible at the obviously place, or because the link's out of date (many are).

Beware that this can take a long time, since it has to look up many servers and most of them are slow.

Parameters:
  • verbose_out (file-like object) - stream to print verbose output to. This is a good way of knowing whether anything's happening, since this process can be slow.
Returns:
list of (midi-file,song-name) pairs each containing a midi.EventStream for each file. May return up to 50, but probably far fewer.

intersearch_midi_files(name, verbose_out=None)

source code 

One method of getting midi files used by find_midi_files.

Looks up the name on Intersearch midi search and tries to parse the results to pull the file urls out.

This is very similar to the vanBasco search, since the results are in roughly the same format. These pages are slightly cleaner.

Parameters:
  • verbose_out (file-like object) - stream to print verbose output to. This is a good way of knowing whether anything's happening, since this process can be slow.
Returns:
list of (midi-file,song-name) pairs each containing a midi.EventStream for each file. May return up to 50, but probably far fewer.

melody_catcher_midi_files(name, verbose_out=None)

source code 

One method of getting midi files used by find_midi_files.

Looks up the name on Melody Catcher midi search and tries to parse the results to pull the file urls out. Melody Catcher is meant primarily as a query-by-humming search, but also offers a title search, which we use.

Parameters:
  • verbose_out (file-like object) - stream to print verbose output to. This is a good way of knowing whether anything's happening, since this process can be slow.
Returns:
list of (midi-file,song-name) pairs each containing a midi.EventStream for each file. May return up to 50, but probably far fewer.

get_linked_file(page_url, filename, timeout=3)

source code 

Often the links on search results pages for MIDI files will be to a page that references the file, rather than to the file itself. Given the url to this page and the filename (also supplied in the search results), this function returns the file itself, if it can find it on the page.

This may raise an exception in the process of fetching the file. This function doesn't catch anything raised by urlopen.

If a link to the file can't be found on the page, we next try getting the file from the same directory as the page. If neither of these works, the last error encountered while try to get a file is raised (although errors reading files linked to on the page will be raised in preference to those from the last-ditch directory attempt).

Parameters:
  • timeout (int) - a timeout used on every url access (default 3 secs)

get_irealb(url, skip=0)

source code 

Get the iReal b format chord sequences from a webpage. The sequences are encoded in a URL (!) which is huuuuge. The argument URL is that of the page containing the URL with the sequences in. If skip is given, skip irealb:// urls are skipped (in case you don't want to download the first on the page).


Variables Details [hide private]

SOURCES

Value:
['jazzpage', 'vanbasco', 'intersearch', 'melodycatcher']