{"id":231,"date":"2017-06-18T18:22:00","date_gmt":"2017-06-18T09:22:00","guid":{"rendered":"http:\/\/gkmsxho.sukkiri.org\/?p=231"},"modified":"2020-03-01T20:00:32","modified_gmt":"2020-03-01T11:00:32","slug":"raspberry-pi%e3%81%a7radiko%e3%81%ae%e3%82%ad%e3%83%bc%e3%83%af%e3%83%bc%e3%83%89%e4%ba%88%e7%b4%84","status":"publish","type":"post","link":"https:\/\/gkmsxho.net\/?p=231","title":{"rendered":"Raspberry Pi\u3067radiko\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u4e88\u7d04"},"content":{"rendered":"<p>\u7686\u3055\u3093\u3001Raspberry Pi\u89e6\u3063\u3066\u307e\u3059\u304b\uff1f\u3000<strong>\u50d5\u306f\u5168\u7136\u89e6\u3063\u3066\u307e\u305b\u3093\u3002<\/strong>\u3067\u3082\u3001\u6bce\u9031\u6642\u9593\u306b\u306a\u308b\u3068\u3001\u81ea\u52d5\u3067\u300e\u5929\u305f\u307e\u300f\u3092\u518d\u751f\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u3001\u5927\u5909\u52a9\u304b\u3063\u3066\u3044\u307e\u3059\u3002Raspberry Pi\uff08\u50d5\u306e\u6301\u3063\u3066\u308b\u306e\u306fRaspberry Pi 2 Model B\u3068\u3044\u3046\u305d\u3046\u3067\u3059\uff09\u3067\u3001radiko\u306e\u518d\u751f\u3084\u9332\u97f3\u3092\u3059\u308b\u65b9\u6cd5\u306f\u3044\u308d\u3093\u306a\u30b5\u30a4\u30c8\u306b\u8f09\u3063\u3066\u307e\u3059\u304c\u3001<strong>\u756a\u7d44\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u4e88\u7d04\u3092\u3059\u308b\u65b9\u6cd5<\/strong>\u304c\u3042\u3093\u307e\u308a\u8f09\u3063\u3066\u3044\u306a\u3044\u3088\u3046\u306a\u306e\u3067\u3001\u50d5\u304c\u9811\u5f35\u3063\u3066\u66f8\u304d\u307e\u3057\u305f\u3002<\/p>\n<p><!--more--><\/p>\n<h2>\u30ad\u30fc\u30ef\u30fc\u30c9\u4e88\u7d04\u3057\u305f\u3044<\/h2>\n<p>\u6709\u5fd7\u306e\u65b9\u3005\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u898b\u308b\u3068\u3001\u3069\u3046\u3084\u3089\u7c21\u5358\u306bradiko\u306e\u756a\u7d44\u8868\u3092\u53d6\u5f97\u3067\u304d\u308b\u6a21\u69d8\u3002\u305d\u308c\u306a\u3089\u3001\u305d\u306e\u756a\u7d44\u8868\u304b\u3089\u30ad\u30fc\u30ef\u30fc\u30c9\u691c\u7d22\u3057\u3066\u3001\u81ea\u52d5\u3067\u4e88\u7d04\u3057\u3066\u307b\u3057\u3044\u3001\u305d\u3046\u601d\u3044\u307e\u3059\u3088\u306d\u3002\u305d\u308c\u306b\u3001\u4f8b\u3048\u3070<strong>\u91ce\u7403\u4e2d\u7d99\u3067\u5ef6\u9577\u306b\u306a\u3063\u305f\u3068\u304d<\/strong>\u3068\u304b\u3001\u305d\u308c\u306b\u5408\u308f\u305b\u3066\u756a\u7d44\u8868\u304c\u66f4\u65b0\u3055\u308c\u308c\u3070\u3001\u307e\u305f\u305d\u306e\u756a\u7d44\u8868\u304b\u3089\u81ea\u52d5\u3067\u4e88\u7d04\u3057\u3066\u304f\u308c\u308b\u308f\u3051\u3067\u3059\u304b\u3089\u3001\u805e\u304d\u9003\u3059\u3053\u3068\u3082\u3042\u308a\u307e\u305b\u3093\u3088\u306d\u3002\u307e\u3042\u3001\u305d\u306e\u70b9\u306b\u95a2\u3057\u3066\u306f\u3001\u534a\u5e74\u9593\u904b\u7528\u3057\u3066\u3001<strong>\u666e\u901a\u306b\u805e\u304d\u9003\u3057\u3066\u3044\u308b<\/strong>\u3093\u3067\u3059\u3051\u3069\u306d\u3002\u591a\u5206\u3001\u305d\u3046\u3044\u3046\u7a81\u767a\u7684\u306a\u3068\u304d\u3063\u3066\u3001\u756a\u7d44\u8868\u66f4\u65b0\u3055\u308c\u3066\u306a\u3044\u3093\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3046\u3044\u3046\u308f\u3051\u3067\u3001\u3042\u3089\u304b\u3058\u3081\u6307\u5b9a\u3057\u305f\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u3063\u3066\u3001radiko\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u756a\u7d44\u8868\u3092\u5143\u306b\u3001\u81ea\u52d5\u3067\u756a\u7d44\u306e\u4e88\u7d04\u3092\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u304d\u307e\u3057\u305f\u3002<\/p>\n<dl>\n<dt>cat \/proc\/version<\/dt>\n<dd>Linux version 3.18.7-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1+bzr2650 &#8211; Linaro GCC 2014.03) ) #755 SMP PREEMPT Thu Feb 12 17:20:48 GMT 2015<\/dd>\n<dt>cat \/etc\/debian_version<\/dt>\n<dd>7.8<\/dd>\n<\/dl>\n<h2>data.dat<\/h2>\n<p>\u3068\u308a\u3042\u3048\u305atab\u3067\u533a\u5207\u3063\u3066\u30ea\u30b9\u30c8\u3092\u4f5c\u308a\u307e\u3059\u3002\u653e\u9001\u5c40\u3001\u30ad\u30fc\u30ef\u30fc\u30c9\u3001\u3084\u308a\u305f\u3044\u3053\u3068\u3001\u3068\u3044\u3046\u611f\u3058\u3067\u3002<\/p>\n<pre><code>QRR\t\u7af9\u9054\u5f69\u5948\tPlay\r\nQRR\t\u5800\u6c5f\u7531\u8863\tPlayRecord<\/code><\/pre>\n<h2>bookByKeywords.sh<\/h2>\n<p>\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5f15\u6570\u306b\u3001\u3055\u3063\u304d\u306edata.dat\u3092\u6e21\u3059\u3068\u826f\u3044\u611f\u3058\u3067\u3059\u3002<\/p>\n<pre><code>#!\/bin\/bash\r\n\r\n# sort\u7528\u306b\r\nLANG=en_US.UTF-8\r\nreserv_table=$1\r\n\r\n# \u4eca\u306e\u6642\u523b\u53d6\u5f97\r\ntouch executed_time.dat\r\n\r\n# \u4e88\u7d04\u8868\u306e\u4e00\u884c\u3054\u3068\u306b\u51e6\u7406\r\ncat ${reserv_table} | while read fileline\r\ndo\r\n  set -- ${fileline}\r\n  #$1 \u5c40\r\n  #$2 \u691c\u7d22\u30ef\u30fc\u30c9\r\n  #$3 \u5b9f\u884c\u30bf\u30a4\u30d7\uff08Play | Record | PlayRecord\uff09\r\n  \r\n  stationID=$1\r\n  search_word=$2\r\n  runtype=$3\r\n  weektable=weektable\\(${stationID}\\).xml \r\n  \r\n  # \u4e00\u9031\u9593\u5206\u306e\u756a\u7d44\u8868\u3092\u53d6\u5f97\r\n  # \u8907\u6570\u30ad\u30fc\u30ef\u30fc\u30c9\u3067\u540c\u3058\u5c40\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u305f\u5834\u5408\u3001\r\n  # \u4f55\u5ea6\u3082\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u306e\u3082\u30a2\u30ec\u306a\u306e\u3067\r\n  if [ ! -e ${weektable} -o executed_time.dat -nt ${weektable} ]; then\r\n    curl -s http:\/\/radiko.jp\/v2\/api\/program\/station\/weekly?station_id=${stationID} \\\r\n      &gt; ${weektable}\r\n  fi\r\n  \r\n  # \u691c\u7d22\u3059\u308b\r\n  search_result=`echo \"grep ${search_word}\" \\\r\n    | xmllint --shell ${weektable} \\\r\n    | sed -n -e \"s\/^.*progs\\[\\(.*\\)\\].*prog\\[\\(.*\\)\\].*\/\\1 \\2\/p\" \\\r\n    | uniq`\r\n  \r\n  # \u691c\u7d22\u7d50\u679c\u306b\u5bfe\u3057\u3066\u51e6\u7406\u3059\u308b\r\n  echo \"${search_result}\" | while read resultline\r\n  do\r\n    set -- ${resultline}\r\n    #$1 progs[x]\r\n    #$2 prog[x]\r\n\r\n    title=`echo \"cat \/radiko\/stations\/station\/scd\/progs[$1]\/prog[$2]\/title\" \\\r\n      | xmllint --shell ${weektable} \\\r\n      | sed -n -e \"s\/^.*&gt;\\(.*\\)&lt;.*\/\\1\/p\" \\\r\n      | sed -e \"y\/ \\t\\\/\/___\/\" `\r\n\r\n    # ft\u306fyyyymmddhhmmss\u3067\u8a18\u8ff0\u3055\u308c\u3066\u3044\u308b\u304c\r\n    # at\u30b3\u30de\u30f3\u30c9\u306e\u6642\u523b\u306fhh:mm mmddyy\u3067\u6307\u5b9a\r\n    ft=`echo \"cat \/radiko\/stations\/station\/scd\/progs[$1]\/prog[$2]\/@ft\" \\\r\n      | xmllint --shell ${weektable} \\\r\n      | sed -n -e \"s\/^.*ft=\\\"..\\(..\\)\\(....\\)\\(..\\)\\(..\\).*\/\\3:\\4 \\2\\1\/p\" `\r\n    dur=`echo \"cat \/radiko\/stations\/station\/scd\/progs[$1]\/prog[$2]\/@dur\" \\\r\n      | xmllint --shell ${weektable} \\\r\n      | sed -n -e \"s\/^.*dur=\\\"\\([^\\\"]*\\)\\\".*\/\\1\/p\" `\r\n    \r\n    # at\u30b3\u30de\u30f3\u30c9\u6574\u5f62\r\n    at_command=\"\/bin\/bash \/home\/pi\/bin\/rec_radiko.sh \\\r\n      $stationID $(($dur + 60)) \/home\/pi\/radio $title $runtype &gt; \/dev\/null 2&gt;&amp;1\"\r\n    \r\n    # \u3059\u3067\u306b\u540c\u3058\u5185\u5bb9\u304cat\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u306a\u3044\u304b\r\n    duplicate_flag=0\r\n    if [ `atq | wc -l` -gt 0 ]; then\r\n      all_jobs=`atq | cut -f1`\r\n      for atqline in ${all_jobs}\r\n      do\r\n        if [ \"`at -c ${atqline} \\\r\n          | sed -n -e \"s%${at_command}%DUPLICATED%p\" `\" \\\r\n          == \"DUPLICATED\" ]\r\n        then\r\n          duplicate_flag=1\r\n          break\r\n        fi\r\n      done\r\n    fi\r\n    \r\n    # \u30d5\u30e9\u30b0\u7acb\u305f\u306a\u304b\u3063\u305f\u3089at\u306b\u8ffd\u52a0\r\n    if [ \"${duplicate_flag}\" == \"0\" ]; then\r\n      echo \"${at_command}\" \\\r\n        | at \"${ft}\" - 1 minute\r\n    fi\r\n  done\r\ndone\r\n\r\n# \u4e00\u5fdc\u3051\u3057\u3068\u304f\r\nrm executed_time.dat<\/code><\/pre>\n<h2>\u4f7f\u3044\u65b9<\/h2>\n<p>crontab -e\u3067\u9069\u5f53\u306a\u6642\u9593\u306b\u56de\u3059\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002\u7d50\u5c40\u3001\u5929\u305f\u307e\u7528\u306a\u306e\u3067\u3001\u50d5\u306f\u6bce\u65e521:45\u306b\u5b9f\u884c\u3057\u3066\u307e\u3059\u3002<\/p>\n<pre><code>45 21 * * * \/home\/pi\/bookByKeywords.sh \/home\/pi\/data.dat &gt; \/dev\/null 2&gt;&amp;1<\/code><\/pre>\n<h2>\u3044\u304b\u304c\u3067\u3057\u3087\u3046<\/h2>\n<p>\u3059\u3067\u306b\u304a\u5206\u304b\u308a\u304b\u3068\u601d\u3044\u307e\u3059\u304c\u3001<strong>\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3060\u3051\u3067\u306fradiko\u306e\u518d\u751f\u3084\u9332\u97f3\u306f\u51fa\u6765\u307e\u305b\u3093<\/strong>\u3002\u306a\u305c\u306a\u3089\u3001\u518d\u751f\u30fb\u9332\u97f3\u3059\u308b\u305f\u3081\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u3001<strong>\u3059\u3067\u306b\u305f\u304f\u3055\u3093\u306e\u65b9\u304c\u7d20\u6674\u3089\u3057\u3044\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u3044\u3066\u3044\u308b\u304b\u3089<\/strong>\u3067\u3059\u3002\u9014\u4e2d\u306bat_command\u3068\u3044\u3046\u5909\u6570\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u3053\u3053\u306b\u5404\u4eba\u601d\u3044\u601d\u3044\u306e\u518d\u751f\u30fb\u9332\u97f3\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u8a18\u8f09\u3057\u3066\u3044\u305f\u3060\u3051\u308c\u3070\u306a\u3068\u601d\u3044\u307e\u3059\u3002\u304a\u305b\u3063\u304b\u3044\u306a\u3053\u3068\u306b\u30011\u5206\u524d\u306b\u518d\u751f\u30fb\u9332\u97f3\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u958b\u59cb\u3059\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3066\u3042\u308a\uff0881\u884c\u76ee\uff09\u3001\u305d\u308c\u306b\u5408\u308f\u305b\u3066\u518d\u751f\u30fb\u9332\u97f3\u6642\u9593\u3082+60sec\u3057\u3066\u3042\u308a\u307e\u3059\uff0860\u884c\u76ee\uff09\u3002<\/p>\n<p>\u3059\u3054\u304f\u304c\u3093\u3070\u3063\u3066\u66f8\u3044\u305f\u306e\u3067\u3001\u306a\u3093\u304b\u306e\u53c2\u8003\u306b\u3057\u3066\u3044\u305f\u3060\u3051\u308b\u3068\u5b09\u3057\u3044\u3067\u3059\u3002\u307e\u305f\u3001\u4f8b\u306b\u3088\u3063\u3066\u50d5\u306flinux\u7d20\u4eba\u3067\u3059\u306e\u3067\u3001\u5185\u5bb9\u306b\u9593\u9055\u3044\u304c\u3042\u3063\u305f\u5834\u5408\u306f\u3001\u7d20\u4eba\u306b\u3082\u5206\u304b\u308b\u3088\u3046\u306b\u8aac\u660e\u3057\u3066\u3044\u305f\u3060\u3051\u308b\u3068\u4fee\u6b63\u3067\u304d\u307e\u3059\u3002\u96e3\u3057\u3044\u3053\u3068\u3092\u8a00\u308f\u308c\u3066\u3082\u300c\u306f\u3042\u2026\u2026\u3002\u305d\u3046\u3067\u3059\u304b\u2026\u2026\u3002\u96e3\u3057\u3044\u3093\u3067\u3059\u306d\u2026\u2026\u300d\u3067\u7d42\u308f\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u306e\u3067\u3001\u4f55\u5352\u3054\u7406\u89e3\u3068\u3054\u5354\u529b\u3092\u8cdc\u308a\u305f\u304f\u3001\u3088\u308d\u3057\u304f\u304a\u9858\u3044\u7533\u3057\u4e0a\u3052\u307e\u3059\u3002<\/p>\n<div class=\"amazlet-box\" style=\"margin-bottom:0px;\">\n<div class=\"amazlet-image\" style=\"float:left;margin:0px 12px 1px 0px;\"><a href=\"http:\/\/www.amazon.co.jp\/exec\/obidos\/ASIN\/B00W4T1HSY\/gkmsxho0e-22\/ref=nosim\/\" name=\"amazletlink\" target=\"_blank\" rel=\"noopener noreferrer\"><img src=\"https:\/\/images-fe.ssl-images-amazon.com\/images\/I\/51tTARfYo9L._SL160_.jpg\" alt=\"Raspberry Pi 2 Model B (1)\" style=\"border: none;\" \/><\/a><\/div>\n<div class=\"amazlet-info\" style=\"line-height:120%; margin-bottom: 10px\">\n<div class=\"amazlet-name\" style=\"margin-bottom:10px;line-height:120%\"><a href=\"http:\/\/www.amazon.co.jp\/exec\/obidos\/ASIN\/B00W4T1HSY\/gkmsxho0e-22\/ref=nosim\/\" name=\"amazletlink\" target=\"_blank\" rel=\"noopener noreferrer\">Raspberry Pi 2 Model B (1)<\/a><\/p>\n<div class=\"amazlet-powered-date\" style=\"font-size:80%;margin-top:5px;line-height:120%\">posted with <a href=\"http:\/\/www.amazlet.com\/\" title=\"amazlet\" target=\"_blank\" rel=\"noopener noreferrer\">amazlet<\/a> at 20.03.01<\/div>\n<\/div>\n<div class=\"amazlet-detail\">Raspberry Pi <br \/>\u58f2\u308a\u4e0a\u3052\u30e9\u30f3\u30ad\u30f3\u30b0: 55,078<\/div>\n<div class=\"amazlet-sub-info\" style=\"float: left;\">\n<div class=\"amazlet-link\" style=\"margin-top: 5px\"><a href=\"http:\/\/www.amazon.co.jp\/exec\/obidos\/ASIN\/B00W4T1HSY\/gkmsxho0e-22\/ref=nosim\/\" name=\"amazletlink\" target=\"_blank\" rel=\"noopener noreferrer\">Amazon.co.jp\u3067\u8a73\u7d30\u3092\u898b\u308b<\/a><\/div>\n<\/div>\n<\/div>\n<div class=\"amazlet-footer\" style=\"clear: left\"><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7686\u3055\u3093\u3001Raspberry Pi\u89e6\u3063\u3066\u307e\u3059\u304b\uff1f\u3000\u50d5\u306f\u5168\u7136\u89e6\u3063\u3066\u307e\u305b\u3093\u3002\u3067\u3082\u3001\u6bce\u9031\u6642\u9593\u306b\u306a\u308b\u3068\u3001\u81ea\u52d5\u3067\u300e\u5929\u305f\u307e\u300f\u3092\u518d\u751f\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u3001\u5927\u5909\u52a9\u304b\u3063\u3066\u3044\u307e\u3059\u3002Raspberry Pi\uff08\u50d5\u306e\u6301\u3063\u3066\u308b\u306e\u306fRaspberry Pi  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":50,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[],"_links":{"self":[{"href":"https:\/\/gkmsxho.net\/index.php?rest_route=\/wp\/v2\/posts\/231"}],"collection":[{"href":"https:\/\/gkmsxho.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gkmsxho.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gkmsxho.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gkmsxho.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=231"}],"version-history":[{"count":2,"href":"https:\/\/gkmsxho.net\/index.php?rest_route=\/wp\/v2\/posts\/231\/revisions"}],"predecessor-version":[{"id":559,"href":"https:\/\/gkmsxho.net\/index.php?rest_route=\/wp\/v2\/posts\/231\/revisions\/559"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gkmsxho.net\/index.php?rest_route=\/wp\/v2\/media\/50"}],"wp:attachment":[{"href":"https:\/\/gkmsxho.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gkmsxho.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gkmsxho.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}