Skip to content

Instantly share code, notes, and snippets.

@cgrice
Created October 5, 2009 20:02
Show Gist options
  • Save cgrice/202395 to your computer and use it in GitHub Desktop.
Save cgrice/202395 to your computer and use it in GitHub Desktop.
if __name__ == '__main__':
droid = android.Android()
# Scan a CD barcode
barcode = droid.scanBarcode()
droid.makeToast('Fetching product info')
EAN = barcode['result']['SCAN_RESULT']
Scanner = RIAAScanner()
# Convert EAN-13 barcode to Amazon ASIN
ASIN = Scanner.get_ASIN(EAN)
droid.makeToast('Scanned: '+Scanner.title+' - '+Scanner.artist)
# Check ASIN against RIAA Radar
safe = Scanner.is_riaa_safe(ASIN)
# Notify User!
if safe == 'safe':
notify = '%s - %s is not associated with RIAA' % (Scanner.artist, Scanner.title)
droid.notify(notify, 'Safe Album', notify)
droid.makeToast(notify)
elif safe == 'unsafe':
notify = '%s - %s is associatd with RIAA' % (Scanner.artist, Scanner.title)
droid.notify(notify, 'Unsafe Album', notify)
droid.makeToast(notify)
else:
droid.makeToast('RIAA association unknown')
droid.exitWithResultOk()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment