itunes-client 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b23fc7101437304af9f40938b9c1ffd1a8c1200
4
- data.tar.gz: f87f2609ef6ae98a19c0ff27ccbf58d9930f5f5b
3
+ metadata.gz: 90f1c739960b99974daed8404c102c5d204eb41f
4
+ data.tar.gz: ffdd3b53d8f68d43c5f17bb877360c53cd26eaea
5
5
  SHA512:
6
- metadata.gz: 5bc6e7a8e429d395d8bd3f1b4a633f0f33d0bc316b268bfe82219d0bd979adfb75542a7c59372e22d328a921b1d59903fc566c57d9e783f1014de0775c021d1b
7
- data.tar.gz: e409d720b89d34548c6c24039530357ecd45725aa5fa98902f6c0b1211274509203a473177f86ee63edc6fe58db5a8ec8eb7dccc91182d6bd0b269201c81a0b7
6
+ metadata.gz: e9a6a01d67ded96ab9dad9c6d171fb06b7b5d4abddff1b64fe5faefd527b893dbd64de7cc6f472daaab26cf0f0f94c1806044a69408ab796b772b45c6115764b
7
+ data.tar.gz: 70ac22b45d7359efd8e67ad0dd35341b0666fa5243e7fcc232453a2f8e9e1e4ccccee40a720eefe13f72275bc4a0e910cc8c883a506a9e27cf5ecd3d3afbd782
@@ -1,3 +1,3 @@
1
1
  module Itunes
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -1,15 +1,17 @@
1
1
  tell application "iTunes"
2
2
  set specified_tracks to (every track whose #{conditions})
3
3
 
4
+
4
5
  set json to "["
5
6
 
6
7
  repeat with specified_track in specified_tracks
7
8
  set props to {}
9
+
8
10
  set end of props to "{"
9
11
  set end of props to ("\"persistent_id\":\"" & persistent ID of specified_track & "\",")
10
- set end of props to ("\"name\":\"" & name of specified_track & "\",")
11
- set end of props to ("\"album\":\"" & album of specified_track & "\",")
12
- set end of props to ("\"artist\":\"" & artist of specified_track & "\",")
12
+ set end of props to ("\"name\":\"" & my escape_quote(name of specified_track) & "\",")
13
+ set end of props to ("\"album\":\"" & my escape_quote(album of specified_track) & "\",")
14
+ set end of props to ("\"artist\":\"" & my escape_quote(artist of specified_track) & "\",")
13
15
  set end of props to ("\"track_count\":\"" & track count of specified_track & "\",")
14
16
  set end of props to ("\"track_number\":\"" & track number of specified_track & "\"")
15
17
  set end of props to "}"
@@ -21,3 +23,24 @@ tell application "iTunes"
21
23
  return json
22
24
 
23
25
  end tell
26
+
27
+
28
+ on escape_quote(someText)
29
+ return replaceText(someText, "\"", "\\\"")
30
+ end escape_quote
31
+
32
+ (*
33
+ https://discussions.apple.com/thread/4588230?start=0&tstart=0
34
+ *)
35
+ on replaceText(someText, oldItem, newItem)
36
+ set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, oldItem}
37
+ try
38
+ set {itemList, AppleScript's text item delimiters} to {text items of someText, newItem}
39
+ set {someText, AppleScript's text item delimiters} to {itemList as text, tempTID}
40
+ on error errorMessage number errorNumber -- oops
41
+ set AppleScript's text item delimiters to tempTID
42
+ error errorMessage number errorNumber -- pass it on
43
+ end try
44
+
45
+ return someText
46
+ end replaceText
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itunes-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryo katsuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-11 00:00:00.000000000 Z
11
+ date: 2013-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake