{"id":376,"date":"2015-08-24T18:40:31","date_gmt":"2015-08-24T17:40:31","guid":{"rendered":"http:\/\/atwrk.phae.eu\/?p=376"},"modified":"2015-09-20T22:09:32","modified_gmt":"2015-09-20T21:09:32","slug":"cd-scan-metadata","status":"publish","type":"post","link":"https:\/\/atwrk.phae.eu\/?p=376","title":{"rendered":"Copyrighted Silence : structuration des donn\u00e9es et m\u00e9tadonn\u00e9es"},"content":{"rendered":"<p>le script <strong>RIP.py :<br \/>\n<\/strong><\/p>\n<pre class=\"height-set:true lang:python decode:true\"># -*- coding: utf-8 -*-\r\n\r\n'''\r\n  RIP PROCESS\r\n  - rip current CD in drive to \"CD_xxx\" directory\r\n  - create current \"rip_info.xml\" in \"CD_XXX\" directory\r\n  - rip audio into .wav files to \"waverip\" subdirectory\r\n  - update global \"rip_process.xml\"\r\n'''\r\n\r\nimport pymedia.removable.cd as cd\r\nimport sys, wave, struct, os\r\nimport datetime\r\nimport lxml.etree as ET\r\nimport random\r\n\r\nimport CS_lib\r\n\r\n# --- LOAD \"rip_process.xml\"\r\nrip_process_path = os.path.normpath(CS_lib.DATAPATH+\"\/rip_process.xml\")\r\nparser = ET.XMLParser(remove_blank_text=True)\r\ntree = ET.parse(rip_process_path, parser)\r\nrip_process = tree.getroot()\r\ncds = rip_process.findall(\"cd\")\r\nnewCD_id = len(cds) + 1\r\n\r\n# --- get basic info\r\nprint(\"Be sure to insert CD in drive...\")\r\nprint(\"and input human readable labels below\")\r\nartistLabel = raw_input(\"Artist : \")\r\nalbumLabel = raw_input(\"Album : \")\r\n\r\nnow = datetime.datetime.now()\r\nprint(\"this is local time\")\r\nprint(now)\r\n\r\n# --- cr\u00e9er le dossier \"CD_xxx\" et son sous-dossier \"waverip\"\r\nos.chdir(CS_lib.DATAPATH)\r\nnewCD_relDir = \"CD_\"+str(newCD_id)\r\nos.mkdir(newCD_relDir)\r\nnewCD_dir = os.path.normpath(CS_lib.DATAPATH+\"\/\"+newCD_relDir)\r\nos.chdir(newCD_relDir)\r\nos.mkdir(\"waverip\")\r\nnewCD_waverip_dir = os.path.normpath(newCD_dir+\"\/waverip\")\r\n\r\n# --- Ouvrir le media, choisir le bon lecteur\r\ncd.init()\t\r\ndriveNo = raw_input(\"Choose drive no. (on \"+str(cd.getCount())+\" drive(s) found) : \")\r\nif driveNo == '':\r\n\tdriveNo = str(CS_lib.default_CDDriveNo)\r\nc = cd.CD(int(driveNo))\r\n\r\n# --- R\u00e9cup\u00e9rer les propri\u00e9t\u00e9s dont la Table Of Content (TOC), et le nombre de pistes\r\ncd_props = c.getProperties()\r\nprint(\"opened cd\")\r\nnewCD_tracksNb = len(cd_props['titles'])\r\nprint (\"with \"+str(newCD_tracksNb)+\" track(s)\")\r\n\r\ncurrentTrackPos = 0\r\nrip_info = ET.Element('rip_info')\r\n\r\n# It\u00e9rer parmi les pistes\r\nfor tr_no in xrange(len(cd_props['titles'])):\r\n\t# --- ouvrir piste\r\n\ttr = c.open(cd_props['titles'][tr_no]) \r\n\t\r\n\t# --- calcul de la dur\u00e9e\r\n\ttr_len_in_frames = int(cd_props['TOC'][tr_no][1])\r\n\ttr_len_in_smp = tr_len_in_frames * 588\r\n\ttr_len_min = (tr_len_in_smp \/ 44100) \/ 60\r\n\ttr_len_sec = (tr_len_in_smp \/ 44100) % 60\r\n\ttr_len_ms = int(((tr_len_in_smp \/ 44100.0) % 1.0) * 1000)\r\n\t\r\n\t# --- affichage donn\u00e9es de piste\r\n\tprint '--- TRACK %s ---' % (tr_no + 1)\r\n\tprint '%s frames = %s samples' % (tr_len_in_frames, tr_len_in_smp) \r\n\tprint '%s\\'%s\\\":%s' % (tr_len_min, tr_len_sec, tr_len_ms)\r\n\t\r\n\t\r\n\t# --- cr\u00e9ation du .wav et extraction des donn\u00e9es vers fichier\r\n\twavefile_path = os.path.normpath(newCD_waverip_dir+\"\/TR_\"+str(tr_no+1)+\".wav\")\r\n\twfile = wave.open(wavefile_path, 'w')\r\n\twfile.setparams((2, 2, 44100, 0, 'NONE', 'not compressed'))\r\n\twfile.writeframes(tr.read(tr_len_in_smp * 4))\r\n\twfile.close()\r\n\ttr.close()\r\n\r\n\t# --- ajout des donn\u00e9es pour rip_info\r\n\ttrack_info = ET.SubElement(rip_info, 'track', id=str(tr_no+1))\r\n\ttrack_length = ET.SubElement(track_info, 'length_in_smp')\r\n\ttrack_length.text = str(tr_len_in_smp)\r\n\ttrack_position = ET.SubElement(track_info, 'position_in_smp')\r\n\ttrack_position.text = str(currentTrackPos)\r\n\tcurrentTrackPos += tr_len_in_smp\r\n\r\n# --- fin du rip, \u00e9jection du CD\t\r\nc.eject()\r\n\r\n# --- Enregistrer \"rip_info.xml\"\r\nxmlstring = ET.tostring(rip_info, pretty_print=True)\r\nrip_info_path = os.path.normpath(newCD_dir+\"\/rip_info.xml\")\r\noutput = open(rip_info_path, 'w')\r\noutput.write(xmlstring)\r\noutput.close()\r\nprint \"rip_info.xml created\"\r\n\r\n\r\n# --- mettre \u00e0 jour rip_process\r\nnewCD = ET.Element(\"cd\", attrib={'id':str(newCD_id)})\r\nartist = ET.SubElement(newCD, 'artist')\r\nartist.text = artistLabel\r\nalbum = ET.SubElement(newCD, 'album')\r\nalbum.text = albumLabel\r\nrip_date = ET.SubElement(newCD, 'rip_date')\r\nnow = datetime.datetime.now()\r\nrip_date.text = now.strftime(\"%Y-%m-%d %H:%M:%S\")\r\ntracksNb = ET.SubElement(newCD, 'tracksNb')\r\ntracksNb.text = str(newCD_tracksNb)\r\n\r\nrip_process.append(newCD)\r\n\r\n#xmlstring = CS_lib.prettify(rip_process)\r\nxmlstring = ET.tostring(rip_process, pretty_print=True)\r\noutput = open(rip_process_path, 'w')\r\noutput.write(xmlstring)\r\noutput.close()\r\nprint \"rip_process.xml updated\"\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>le fichier .\/<strong>rip_process.xml<\/strong> :<\/p>\n<pre class=\"height-set:true height:400 lang:xhtml decode:true\">&lt;rip_process&gt;\r\n  &lt;cd id=\"1\"&gt;\r\n    &lt;artist&gt;Margo&lt;\/artist&gt;\r\n    &lt;album&gt;Furtive Furies&lt;\/album&gt;\r\n    &lt;rip_date&gt;2015-09-16 23:53:10&lt;\/rip_date&gt;\r\n    &lt;tracksNb&gt;13&lt;\/tracksNb&gt;\r\n  &lt;\/cd&gt;\r\n  &lt;cd id=\"2\"&gt;\r\n    &lt;artist&gt;Motorhead&lt;\/artist&gt;\r\n    &lt;album&gt;Dirty Love&lt;\/album&gt;\r\n    &lt;rip_date&gt;2015-09-16 23:59:39&lt;\/rip_date&gt;\r\n    &lt;tracksNb&gt;11&lt;\/tracksNb&gt;\r\n  &lt;\/cd&gt;\r\n  &lt;cd id=\"3\"&gt;\r\n    &lt;artist&gt;Portishead&lt;\/artist&gt;\r\n    &lt;album&gt;Portishead&lt;\/album&gt;\r\n    &lt;rip_date&gt;2015-09-17 00:06:08&lt;\/rip_date&gt;\r\n    &lt;tracksNb&gt;11&lt;\/tracksNb&gt;\r\n  &lt;\/cd&gt;\r\n  &lt;cd id=\"4\"&gt;\r\n    &lt;artist&gt;Laurie Anderson&lt;\/artist&gt;\r\n    &lt;album&gt;Bright Red&lt;\/album&gt;\r\n    &lt;rip_date&gt;2015-09-17 00:49:39&lt;\/rip_date&gt;\r\n    &lt;tracksNb&gt;14&lt;\/tracksNb&gt;\r\n  &lt;\/cd&gt;\r\n  &lt;cd id=\"5\"&gt;\r\n    &lt;artist&gt;MIS (Mexican Institute of Sound)&lt;\/artist&gt;\r\n    &lt;album&gt;Politico&lt;\/album&gt;\r\n    &lt;rip_date&gt;2015-09-17 01:01:02&lt;\/rip_date&gt;\r\n    &lt;tracksNb&gt;13&lt;\/tracksNb&gt;\r\n  &lt;\/cd&gt;\r\n  &lt;cd id=\"6\"&gt;\r\n    &lt;artist&gt;Robert Wyatt&lt;\/artist&gt;\r\n    &lt;album&gt;Rock Bottom&lt;\/album&gt;\r\n    &lt;rip_date&gt;2015-09-17 01:43:47&lt;\/rip_date&gt;\r\n    &lt;tracksNb&gt;6&lt;\/tracksNb&gt;\r\n  &lt;\/cd&gt;\r\n  &lt;cd id=\"7\"&gt;\r\n    &lt;artist&gt;KMFDM&lt;\/artist&gt;\r\n    &lt;album&gt;WWIII&lt;\/album&gt;\r\n    &lt;rip_date&gt;2015-09-17 01:51:50&lt;\/rip_date&gt;\r\n    &lt;tracksNb&gt;11&lt;\/tracksNb&gt;\r\n  &lt;\/cd&gt;\r\n&lt;\/rip_process&gt;\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>exemple d&rsquo;un fichier .\/CD_xxx\/<strong>rip_info.xml<\/strong> :<\/p>\n<pre class=\"height-set:true height:400 lang:xhtml decode:true\">&lt;rip_info&gt;\r\n  &lt;track id=\"1\"&gt;\r\n    &lt;length_in_smp&gt;7952700&lt;\/length_in_smp&gt;\r\n    &lt;position_in_smp&gt;0&lt;\/position_in_smp&gt;\r\n  &lt;\/track&gt;\r\n  &lt;track id=\"2\"&gt;\r\n    &lt;length_in_smp&gt;11660628&lt;\/length_in_smp&gt;\r\n    &lt;position_in_smp&gt;7952700&lt;\/position_in_smp&gt;\r\n  &lt;\/track&gt;\r\n  &lt;track id=\"3\"&gt;\r\n    &lt;length_in_smp&gt;14457156&lt;\/length_in_smp&gt;\r\n    &lt;position_in_smp&gt;19613328&lt;\/position_in_smp&gt;\r\n  &lt;\/track&gt;\r\n  &lt;track id=\"4\"&gt;\r\n    &lt;length_in_smp&gt;10254132&lt;\/length_in_smp&gt;\r\n    &lt;position_in_smp&gt;34070484&lt;\/position_in_smp&gt;\r\n  &lt;\/track&gt;\r\n  &lt;track id=\"5\"&gt;\r\n    &lt;length_in_smp&gt;12640236&lt;\/length_in_smp&gt;\r\n    &lt;position_in_smp&gt;44324616&lt;\/position_in_smp&gt;\r\n  &lt;\/track&gt;\r\n  &lt;track id=\"6\"&gt;\r\n    &lt;length_in_smp&gt;8336076&lt;\/length_in_smp&gt;\r\n    &lt;position_in_smp&gt;56964852&lt;\/position_in_smp&gt;\r\n  &lt;\/track&gt;\r\n  &lt;track id=\"7\"&gt;\r\n    &lt;length_in_smp&gt;8220828&lt;\/length_in_smp&gt;\r\n    &lt;position_in_smp&gt;65300928&lt;\/position_in_smp&gt;\r\n  &lt;\/track&gt;\r\n  &lt;track id=\"8\"&gt;\r\n    &lt;length_in_smp&gt;15575532&lt;\/length_in_smp&gt;\r\n    &lt;position_in_smp&gt;73521756&lt;\/position_in_smp&gt;\r\n  &lt;\/track&gt;\r\n  &lt;track id=\"9\"&gt;\r\n    &lt;length_in_smp&gt;10181808&lt;\/length_in_smp&gt;\r\n    &lt;position_in_smp&gt;89097288&lt;\/position_in_smp&gt;\r\n  &lt;\/track&gt;\r\n  &lt;track id=\"10\"&gt;\r\n    &lt;length_in_smp&gt;7172424&lt;\/length_in_smp&gt;\r\n    &lt;position_in_smp&gt;99279096&lt;\/position_in_smp&gt;\r\n  &lt;\/track&gt;\r\n  &lt;track id=\"11\"&gt;\r\n    &lt;length_in_smp&gt;9042852&lt;\/length_in_smp&gt;\r\n    &lt;position_in_smp&gt;106451520&lt;\/position_in_smp&gt;\r\n  &lt;\/track&gt;\r\n  &lt;track id=\"12\"&gt;\r\n    &lt;length_in_smp&gt;13088880&lt;\/length_in_smp&gt;\r\n    &lt;position_in_smp&gt;115494372&lt;\/position_in_smp&gt;\r\n  &lt;\/track&gt;\r\n  &lt;track id=\"13\"&gt;\r\n    &lt;length_in_smp&gt;32832156&lt;\/length_in_smp&gt;\r\n    &lt;position_in_smp&gt;128583252&lt;\/position_in_smp&gt;\r\n  &lt;\/track&gt;\r\n&lt;\/rip_info&gt;\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>le script RIP.py : # -*- coding: utf-8 -*- \u00a0\u00bb&rsquo; RIP PROCESS &#8211; rip current CD in drive to \u00ab\u00a0CD_xxx\u00a0\u00bb directory &#8211; create current \u00ab\u00a0rip_info.xml\u00a0\u00bb in \u00ab\u00a0CD_XXX\u00a0\u00bb directory &#8211; rip audio into .wav files to \u00ab\u00a0waverip\u00a0\u00bb subdirectory &#8211; update global \u00ab\u00a0rip_process.xml\u00a0\u00bb \u00a0\u00bb&rsquo; import pymedia.removable.cd as cd import sys, wave, struct, os import datetime import lxml.etree &hellip; <a href=\"https:\/\/atwrk.phae.eu\/?p=376\" class=\"more-link\">Continuer la lecture de <span class=\"screen-reader-text\">Copyrighted Silence : structuration des donn\u00e9es et m\u00e9tadonn\u00e9es<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[229,2],"tags":[],"_links":{"self":[{"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=\/wp\/v2\/posts\/376"}],"collection":[{"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=376"}],"version-history":[{"count":9,"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=\/wp\/v2\/posts\/376\/revisions"}],"predecessor-version":[{"id":392,"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=\/wp\/v2\/posts\/376\/revisions\/392"}],"wp:attachment":[{"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}