rubynpr 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +58 -0
  3. data/README.txt +53 -0
  4. data/Rakefile +16 -0
  5. data/bin/rubynpr +0 -0
  6. data/lib/rubynpr/audio.rb +43 -0
  7. data/lib/rubynpr/byline.rb +20 -0
  8. data/lib/rubynpr/client.rb +192 -0
  9. data/lib/rubynpr/content.rb +17 -0
  10. data/lib/rubynpr/exception.rb +34 -0
  11. data/lib/rubynpr/image.rb +34 -0
  12. data/lib/rubynpr/item.rb +25 -0
  13. data/lib/rubynpr/list.rb +47 -0
  14. data/lib/rubynpr/message.rb +15 -0
  15. data/lib/rubynpr/organization.rb +22 -0
  16. data/lib/rubynpr/parent.rb +24 -0
  17. data/lib/rubynpr/product.rb +32 -0
  18. data/lib/rubynpr/pull_quote.rb +12 -0
  19. data/lib/rubynpr/related_link.rb +26 -0
  20. data/lib/rubynpr/result_parser.rb +18 -0
  21. data/lib/rubynpr/show.rb +32 -0
  22. data/lib/rubynpr/story.rb +91 -0
  23. data/lib/rubynpr/subcategory.rb +17 -0
  24. data/lib/rubynpr.rb +28 -0
  25. data/test/audio_test.rb +24 -0
  26. data/test/byline_test.rb +10 -0
  27. data/test/client_test.rb +44 -0
  28. data/test/fixtures/audio.yml +32 -0
  29. data/test/fixtures/byline.yml +6 -0
  30. data/test/fixtures/client.yml +190 -0
  31. data/test/fixtures/image.yml +10 -0
  32. data/test/fixtures/item.yml +15 -0
  33. data/test/fixtures/list.yml +78 -0
  34. data/test/fixtures/list_text.xml +3 -0
  35. data/test/fixtures/organization.yml +11 -0
  36. data/test/fixtures/parent.yml +6 -0
  37. data/test/fixtures/product.yml +9 -0
  38. data/test/fixtures/pullquote.yml +6 -0
  39. data/test/fixtures/relatedlink.yml +6 -0
  40. data/test/fixtures/show.yml +6 -0
  41. data/test/fixtures/stories.yml +522 -0
  42. data/test/fixtures/story.yml +124 -0
  43. data/test/fixtures/subcategory.yml +59 -0
  44. data/test/fixtures.rb +86 -0
  45. data/test/image_test.rb +16 -0
  46. data/test/item_test.rb +18 -0
  47. data/test/list_test.rb +17 -0
  48. data/test/organization_test.rb +16 -0
  49. data/test/parent_test.rb +13 -0
  50. data/test/product_test.rb +16 -0
  51. data/test/pullquote_test.rb +11 -0
  52. data/test/related_link_test.rb +9 -0
  53. data/test/show_test.rb +12 -0
  54. data/test/story_list_test.rb +21 -0
  55. data/test/story_test.rb +50 -0
  56. data/test/subcategory_test.rb +15 -0
  57. data/test/test_helper.rb +12 -0
  58. data/test/test_rubynpr.rb +1 -0
  59. metadata +150 -0
@@ -0,0 +1,26 @@
1
+ module NPR
2
+ # RelatedLink represents any of the links that are included with an NPR story linking
3
+ # to related NPR content. A RelatedLink has its respective caption and two URIs associated
4
+ # with it: one which returns HTML and one which is the API URI for a story.
5
+ #
6
+ # * <tt>caption</tt> - caption for a related link
7
+ # * <tt>uri</tt> - a hash containing URIs to access both the HTML and API representations
8
+ # of a related story. Use options <tt>:html</tt> or <tt>:api</tt>.
9
+ #
10
+ # ==== Example
11
+ # <tt>@related_link = some_story.related_links[0].uri[:api]</tt>
12
+ #
13
+ class RelatedLink < Content
14
+ attr_accessor :caption, :uri
15
+
16
+ private
17
+ def new_from_nprml(rel_link_nprml)
18
+ @caption = Hpricot.XML(rel_link_nprml.at('caption').html).innerText
19
+ uri = rel_link_nprml.search('link')
20
+
21
+ @uri = {}
22
+ @uri[:html] = uri[0].html unless uri[0].nil?
23
+ @uri[:api] = uri[1].html unless uri[1].nil?
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'hpricot'
3
+
4
+ module NPR
5
+ class ResultParser
6
+ def parse(raw_results)
7
+ h_raw_results = Hpricot.XML(raw_results)
8
+ result = transform_nprml(h_raw_results) if h_raw_results.search('nprml')
9
+ end
10
+
11
+ private
12
+ def transform_nprml(raw_results)
13
+ # handle things according to whether you're dealing with a list of stories or topics
14
+ list = raw_results.at('list')
15
+ raw_results.search('story').empty? ? List.new(list) : StoryList.new(list)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,32 @@
1
+
2
+ module NPR
3
+ # More often than not, a Story was presented as part of an NPR show. If a Story was
4
+ # presented as part of a show, it can be accessed from a story's <tt>show</tt> attribute.
5
+ # A Show has:
6
+ #
7
+ # * <tt>program</tt> - a hash with information about the program. Use <tt>@some_story.show.program[:name]</tt> to
8
+ # access the name of the show. <tt>@some_story.show.program[:id]</tt> accesses the ID of the show and
9
+ # <tt>@some_story.show.program[:code]</tt> is the NPR abbreviation for the given show
10
+ # * <tt>show_date</tt> - a DateTime object with the date of the show.
11
+ # * <tt>segment</tt> - the segment of the given show
12
+ #
13
+ class Show < Content
14
+ attr_accessor :program, :show_date, :segment
15
+
16
+ PROGRAM_ATTRS = [:id, :code]
17
+
18
+ alias_method :date, :show_date
19
+
20
+ private
21
+ def new_from_nprml(show_nprml)
22
+ return nil if show_nprml.nil?
23
+ @segment = show_nprml.at('segNum').html
24
+ @show_date = DateTime.strptime(show_nprml.at('showDate').html, RESULT_DATE_FORMAT)
25
+
26
+ prog = show_nprml.at('program')
27
+ @program = { :name => prog.html,
28
+ :id => prog[:id],
29
+ :code => prog[:code] }
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,91 @@
1
+
2
+ module NPR
3
+ RESULT_DATE_FORMAT = "%a, %d %b %Y %H:%M:%S %z"
4
+
5
+ # Story represents an NPR story. ruby-npr gives you the following attributes to work with on a Story object:
6
+ # * <tt>id</tt> - unique NPR identifier for each story
7
+ # * <tt>title</tt> - the title of the story.
8
+ # * <tt>subtitle</tt> - a short description of the story
9
+ # * <tt>bylines</tt> - a listing of the story's author(s)
10
+ # * <tt>teaser</tt> - summary of the story
11
+ # * <tt>mini_teaser</tt> - an even shorter summary of the story
12
+ # * <tt>slug</tt> - the main association for the returned story, be it a topic, series, column or other list from NPR
13
+ # * <tt>organization</tt> - the owner of the story
14
+ # * <tt>story_date</tt> - the date the story was published
15
+ # * <tt>publication_date</tt> - the date the story was initially published to NPR. Also can be accessed by <tt>pub_date</tt>
16
+ # * <tt>last_modified</tt> - the date the story was last modified in any sort of way
17
+ # * <tt>audio</tt> - a story's audio attachment
18
+ # * <tt>show</tt> - which show this story originated from (if there was one)
19
+ # * <tt>parents</tt> - parent topics for this story, i.e. economy, health &amp; science, etc.
20
+ # * <tt>products</tt> - any associated products that are included with the story. Usually books.
21
+ # * <tt>related_links</tt> - links to NPR content related to the given story
22
+ # * <tt>html_text</tt> - returns an array of the paragraphs of the text of the story. Includes all the HTML links
23
+ # and such as originally included in the body of the story.
24
+ # * <tt>plain_text</tt> - also returns an array of the paragraphs of the text of the story. Does not include any HTML.
25
+ # * <tt>images</tt> - any images associated with a story
26
+ # * <tt>link</tt> - a hash with links to the story. Use <tt>@some_story.link[:html]</tt> to access the web page for the given
27
+ # Story. Use <tt>@some_story.link[:api]</tt> to access the API representation of the given Story.
28
+ #
29
+ class Story < Content
30
+ attr_accessor :id, :title, :teaser, :mini_teaser, :slug, :organization, :story_date, :last_modified,
31
+ :publication_date, :subtitle, :audio, :show, :parents, :short_title, :keywords,
32
+ :priority_keywords, :products, :links, :related_links, :bylines, :html_text, :plain_text,
33
+ :images, :link
34
+
35
+ #--
36
+ # b/c I'm just as lazy as the next SuzieQ.
37
+ alias_method :pub_date, :publication_date
38
+ alias_method :org, :organization
39
+
40
+ private
41
+ def new_from_nprml(story_nprml)
42
+ @id = story_nprml[:id]
43
+ @title = story_nprml.at('title').html if story_nprml.at('title')
44
+ @subtitle = story_nprml.at('subtitle').html if story_nprml.at('subtitle')
45
+ @slug = story_nprml.at('slug').html if story_nprml.at('slug')
46
+ @teaser = Hpricot.XML(story_nprml.at('teaser').html).innerText if story_nprml.at('teaser')
47
+ @mini_teaser = Hpricot.XML(story_nprml.at('miniTeaser').html).innerText if story_nprml.at('miniTeaser')
48
+ @link = { :html => story_nprml.at("link[@type='html']").html,
49
+ :api => story_nprml.at("link[@type='api']").html }
50
+
51
+ @publication_date = DateTime.strptime(story_nprml.at('pubDate').html, RESULT_DATE_FORMAT) if story_nprml.at('pubDate')
52
+ @story_date = DateTime.strptime(story_nprml.at('storyDate').html, RESULT_DATE_FORMAT) if story_nprml.at('storyDate')
53
+ @last_modified = DateTime.strptime(story_nprml.at('lastModifiedDate').html, RESULT_DATE_FORMAT) if story_nprml.at('lastModifiedDate')
54
+
55
+ @organization = Organization.new(story_nprml.at('organization')) if story_nprml.at('organization')
56
+ @show = Show.new(story_nprml.at('show')) if story_nprml.at('show')
57
+ @audio = Audio.new(story_nprml.at('audio')) if story_nprml.at('audio')
58
+
59
+ process_text(story_nprml.search('text'))
60
+ process_text(story_nprml.search('textWithHtml'), true)
61
+
62
+ story_nprml.search('image') { |image| process_story_images(image) }
63
+ story_nprml.search('parent') { |parent| process_story_parents(parent) }
64
+ story_nprml.search('byline') { |byline| process_story_bylines(byline) }
65
+ story_nprml.search('product') { |product| process_story_products(product) }
66
+ story_nprml.search('relatedLink') { |link| process_related_links(link) }
67
+ end
68
+
69
+ def process_text(text_nprml, with_html = false)
70
+ unless text_nprml.empty?
71
+ ivar = with_html ? '@html_text' : '@plain_text'
72
+ instance_variable_set(ivar, [])
73
+ text_nprml.search('paragraph').each do |paragraph|
74
+ instance_variable_get(ivar) << Hpricot.XML(paragraph.html).innerText.strip
75
+ end
76
+ end
77
+ end
78
+
79
+ def process_related_links(nprml)
80
+ @related_links ||= []
81
+ @related_links << RelatedLink.new(nprml)
82
+ end
83
+
84
+ def method_missing(method_name, *args)
85
+ return nil unless method_name.to_s =~ /process_story_(bylines|parents|products|images)/
86
+ klass = method_name.to_s.split('_').last
87
+ instance_variable_set("@#{ klass }", []) if instance_variable_get("@#{ klass }").nil?
88
+ instance_variable_get("@#{ klass }") << NPR.const_get(klass.capitalize.chop).new(args[0])
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,17 @@
1
+ module NPR
2
+ # Often, Items are returned by name alphabetically. Each letter would correspond to a Subcategory.
3
+ # A Subcategory has:
4
+ #
5
+ # * <tt>name</tt> - the name of the Subcategory
6
+ # * <tt>items</tt> - the Items that belong to the Subcategory
7
+ #
8
+ class Subcategory < Content
9
+ attr_accessor :name, :items
10
+
11
+ private
12
+ def new_from_nprml(subcategory_nprml)
13
+ @name = subcategory_nprml[:name]
14
+ @items = NPR.process_elements('item', subcategory_nprml)
15
+ end
16
+ end
17
+ end
data/lib/rubynpr.rb ADDED
@@ -0,0 +1,28 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'rubynpr/content'
5
+ require 'rubynpr/audio'
6
+ require 'rubynpr/byline'
7
+ require 'rubynpr/client'
8
+ require 'rubynpr/exception'
9
+ require 'rubynpr/image'
10
+ require 'rubynpr/item'
11
+ require 'rubynpr/list'
12
+ require 'rubynpr/message'
13
+ require 'rubynpr/organization'
14
+ require 'rubynpr/parent'
15
+ require 'rubynpr/product'
16
+ require 'rubynpr/pull_quote'
17
+ require 'rubynpr/related_link'
18
+ require 'rubynpr/result_parser'
19
+ require 'rubynpr/show'
20
+ require 'rubynpr/story'
21
+ require 'rubynpr/subcategory'
22
+ require 'rubygems'
23
+ require 'ruby-debug'
24
+ require 'date'
25
+
26
+ class RubyNPR
27
+ VERSION = '0.0.1'
28
+ end
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__) + '/test_rubynpr.rb'
2
+
3
+ class AudioFromNPRMLTest < Test::Unit::TestCase
4
+ def test_should_create_audio_without_rightsholder
5
+ audio = Audio.new(Hpricot.XML(Fixtures::Audio.with_no_rightsholder_no_mp3rights).at('audio'))
6
+ assert_equal '95608227', audio.id
7
+ assert_equal '', audio.title
8
+ assert_equal 'primary', audio.type
9
+ assert_equal '748', audio.duration
10
+ assert_equal 'http://api.npr.org/m3u/195608227-30ec0e.m3u&amp;ft=3&amp;f=1007', audio.formats[:mp3]
11
+ assert_equal 'http://www.npr.org/templates/dmg/dmg_wmref_em.php?id=95608227&amp;type=1&amp;mtype=WM&amp;ft=3&amp;f=1007', audio.formats[:wm]
12
+ assert_equal 'http://www.npr.org/templates/dmg/dmg_rpm.rpm?id=95608227&amp;type=1&amp;mtype=RM&amp;ft=3&amp;f=1007', audio.formats[:rm]
13
+ end
14
+
15
+ def test_should_create_audio_without_formats
16
+ audio = Audio.new(Hpricot.XML(Fixtures::Audio.with_no_formats).at('audio'))
17
+ assert_nil audio.formats
18
+ end
19
+
20
+ def test_should_create_audio_with_mp3_rights
21
+ audio = Audio.new(Hpricot.XML(Fixtures::Audio.with_mp3_rights).at('audio'))
22
+ assert_equal 'Streaming', audio.mp3_rights
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/test_rubynpr.rb'
2
+
3
+ class BylineFromNPRMLTest < Test::Unit::TestCase
4
+ def test_should_create_a_byline
5
+ byline = Byline.new(Hpricot.XML(Fixtures::Byline.typical_byline).at('byline'))
6
+ assert_equal '95703247', byline.id
7
+ assert_equal 'Mara Liasson', byline.name
8
+ assert_equal '1930401', byline.person
9
+ end
10
+ end
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/test_rubynpr.rb'
2
+
3
+ class ClientTest < Test::Unit::TestCase
4
+ def test_should_raise_exception_if_query_attempted_without_api_key
5
+ client = Client.new
6
+ assert_raise(InvalidAPIKey) { client.query(:id => '95604667') }
7
+ end
8
+
9
+ def test_should_raise_exception_if_NPR_is_having_issues
10
+ client = Client.new(:api_key => 'bogus_api_key')
11
+ Net::HTTP.stubs(:new).returns(mock(:get => ['headers', Fixtures::Client.npr_system_issues]))
12
+ assert_raise(NPRSystemIssues) { client.query(:id => '95604667') }
13
+ end
14
+
15
+ def test_should_raise_exception_if_bad_api_key_given
16
+ client = Client.new(:api_key => 'bogus_api_key')
17
+ Net::HTTP.stubs(:new).returns(mock(:get => ['headers', Fixtures::Client.bad_api_key]))
18
+ assert_raise(InvalidAPIKey) { client.query(:id => '95604667') }
19
+ end
20
+
21
+ def test_should_raise_exception_if_deactivated_api_key_given
22
+ client = Client.new(:api_key => 'inactive_api_key')
23
+ Net::HTTP.stubs(:new).returns(mock(:get => ['headers', Fixtures::Client.deactivated_api_key]))
24
+ assert_raise(DeactivatedAPIKey) { client.query(:id => '95604667') }
25
+ end
26
+
27
+ def test_should_raise_exception_if_invalid_list_requested
28
+ client = Client.new(:api_key => 'ridiculous_api_key')
29
+ Net::HTTP.stubs(:new).returns(mock(:get => ['headers', Fixtures::Client.invalid_list]))
30
+ assert_raise(InvalidList) { client.list(:id => '3210') }
31
+ end
32
+
33
+ def test_should_raise_exception_if_invalid_query_generated
34
+ client = Client.new(:api_key => 'some_api_key_that_works')
35
+ assert_raise(InvalidQueryOptions) { client.query(:start_date => Time.utc(2008, 9, 30)) }
36
+ end
37
+
38
+ def test_should_create_warnings_from_query
39
+ client = Client.new(:api_key => 'some_api_key_that_works')
40
+ Net::HTTP.stubs(:new).returns(mock(:get => ['headers', Fixtures::Client.results_with_warning]))
41
+ client.query(:id => 1017, :end_date => Time.utc(2015, 12, 31))
42
+ assert_equal 1, client.warnings.size
43
+ end
44
+ end
@@ -0,0 +1,32 @@
1
+ with_no_rightsholder_no_mp3rights: >
2
+ <audio id="95608227" type="primary">
3
+ <title/>
4
+ <duration>748</duration>
5
+ <format>
6
+ <mp3>http://api.npr.org/m3u/195608227-30ec0e.m3u&amp;ft=3&amp;f=1007</mp3>
7
+ <wm>http://www.npr.org/templates/dmg/dmg_wmref_em.php?id=95608227&amp;type=1&amp;mtype=WM&amp;ft=3&amp;f=1007</wm>
8
+ <rm>http://www.npr.org/templates/dmg/dmg_rpm.rpm?id=95608227&amp;type=1&amp;mtype=RM&amp;ft=3&amp;f=1007</rm>
9
+ </format>
10
+ <rightsHolder/>
11
+ </audio>
12
+
13
+
14
+ with_no_formats: >
15
+ <audio id="95906239" type="primary">
16
+ <title/>
17
+ <duration>0</duration>
18
+ <format/>
19
+ <rightsHolder/>
20
+ </audio>
21
+
22
+ with_mp3_rights: >
23
+ <audio id="91280057" primary="true">
24
+ <title/>
25
+ <duration>425</duration>
26
+ <format>
27
+ <mp3 rights="Streaming">http://api.npr.org/m3u/191280057-bd7a36.m3u</mp3>
28
+ <wm>http://api.npr.org/templates/dmg/dmg_wmref_em.php?id=91280057&type=1&mtype=WM</wm>
29
+ <rm>http://api.npr.org/templates/dmg/dmg_wmref_em.php?id=91280057&type=1&mtype=RM</rm>
30
+ </format>
31
+ <rightsHolder/>
32
+ </audio>
@@ -0,0 +1,6 @@
1
+ typical_byline: >
2
+ <byline id="95703247">
3
+ <name personId="1930401">Mara Liasson</name>
4
+ <link type="html">http://www.npr.org/templates/story/story.php?storyId=1930401&amp;ft=3&amp;f=95702879</link>
5
+ <link type="api">http://api.npr.org/query?id=1930401&amp;apiKey=MDAyMDAzMjg3MDEyMjQwNDk0Mzg5YzIwZA001</link>
6
+ </byline>
@@ -0,0 +1,190 @@
1
+ npr_system_issues: >
2
+ <?xml version="1.0"?>
3
+ <messages>
4
+ <message id="101" level="error">
5
+ <text>
6
+ NPR is experiencing system issues at this time. Please try this request again later.
7
+ </text>
8
+ <timestamp>1214266426.87</timestamp>
9
+ </message>
10
+ </messages>
11
+ </xml>
12
+
13
+ bad_api_key: >
14
+ <?xml version="1.0"?>
15
+ <messages>
16
+ <message id="310" level="error">
17
+ <text>
18
+ The API key passed in (bogus_api_test_key) was invalid or no API key was passed in. Please register for a valid API key.
19
+ </text>
20
+ <timestamp>1214266426.87</timestamp>
21
+ </message>
22
+ </messages>
23
+ </xml>
24
+
25
+ deactivated_api_key: >
26
+ <?xml version="1.0"?>
27
+ <messages>
28
+ <message id="311" level="error">
29
+ <text>
30
+ The API key passed in (inactive_api_test_key) was deactivated. We will contact the email associated with this API key, but you may also contact us by visiting http://www.npr.org/contact/ and selecting the office 'Online / Technical Support'.
31
+ </text>
32
+ <timestamp>1214266426.87</timestamp>
33
+ </message>
34
+ </messages>
35
+ </xml>
36
+
37
+ invalid_list: >
38
+ <?xml version="1.0"?>
39
+ <errorResponse error="true">
40
+ <message><The requested list could not be found.></message>
41
+ </errorResponse>
42
+
43
+ results_with_warning: >
44
+ <?xml version="1.0"?>
45
+ <nprml version="0.9">
46
+ <message id="306" level="warning">
47
+ <text>Your parameter (endDate=2045-12-31) was in the future, so it was reset to now.</text>
48
+ <timestamp>1224953395.25</timestamp>
49
+ </message>
50
+ <list>
51
+ <title>Morning Edition</title>
52
+ <teaser><![CDATA[For more than two decades, NPR's Morning Edition has prepared listeners for the day ahead with two hours of up-to-the-minute news, background analysis, commentary, and coverage of arts and sports. With nearly 13 million listeners, Morning Edition draws public radio's largest audience.]]></teaser>
53
+ <miniTeaser><![CDATA[For more than two decades, NPR's Morning Edition has prepared listeners for the day ahead.]]></miniTeaser>
54
+ <story id="96063076">
55
+ <link type="html">http://www.npr.org/templates/story/story.php?storyId=96063076&amp;ft=3&amp;f=3</link>
56
+ <link type="api">http://api.npr.org/query?id=96063076&amp;apiKey=MDAyMDAzMjg3MDEyMjQ1Mjg4OTkxZjcyOQ001</link>
57
+ <title>Survey: U.S. Doctors Regularly Prescribe Placebos</title>
58
+ <subtitle/>
59
+ <shortTitle/>
60
+ <teaser><![CDATA[The American Medical Association says doctors shouldn't prescribe placebos because the practice undermines trust. But in a new study, about half of the physicians surveyed say they regularly prescribe placebos &mdash; and that patients are mostly unaware.]]></teaser>
61
+ <miniTeaser><![CDATA[The doctors say they regularly prescribe placebos &mdash; and that patients are mostly unaware.]]></miniTeaser>
62
+ <slug>Health Care</slug>
63
+ <storyDate>Fri, 24 Oct 2008 06:00:00 -0400</storyDate>
64
+ <pubDate>Fri, 24 Oct 2008 18:11:00 -0400</pubDate>
65
+ <lastModifiedDate>Fri, 24 Oct 2008 11:50:17 -0400</lastModifiedDate>
66
+ <show>
67
+ <program id="3" code="ME">Morning Edition</program>
68
+ <showDate>Fri, 24 Oct 2008 06:00:00 -0400</showDate>
69
+ <segNum>4</segNum>
70
+ </show>
71
+ <keywords/>
72
+ <priorityKeywords/>
73
+ <organization orgId="1">
74
+ <name>National Public Radio</name>
75
+ <website type="Home Page">http://www.npr.org/</website>
76
+ </organization>
77
+ <parent id="1066" type="topic">
78
+ <title>Your Health</title>
79
+ <link type="html">http://www.npr.org/templates/topics/topic.php?topicId=1066&amp;ft=3&amp;f=3</link>
80
+ <link type="api">http://api.npr.org/query?id=1066&amp;apiKey=MDAyMDAzMjg3MDEyMjQ1Mjg4OTkxZjcyOQ001</link>
81
+ </parent>
82
+ <parent id="1027" type="primaryTopic">
83
+ <title>Health Care</title>
84
+ <link type="html">http://www.npr.org/templates/topics/topic.php?topicId=1027&amp;ft=3&amp;f=3</link>
85
+ <link type="api">http://api.npr.org/query?id=1027&amp;apiKey=MDAyMDAzMjg3MDEyMjQ1Mjg4OTkxZjcyOQ001</link>
86
+ </parent>
87
+ <parent id="1027" type="topic">
88
+ <title>Health Care</title>
89
+ <link type="html">http://www.npr.org/templates/topics/topic.php?topicId=1027&amp;ft=3&amp;f=3</link>
90
+ <link type="api">http://api.npr.org/query?id=1027&amp;apiKey=MDAyMDAzMjg3MDEyMjQ1Mjg4OTkxZjcyOQ001</link>
91
+ </parent>
92
+ <parent id="1024" type="topic">
93
+ <title>Research News</title>
94
+ <link type="html">http://www.npr.org/templates/topics/topic.php?topicId=1024&amp;ft=3&amp;f=3</link>
95
+ <link type="api">http://api.npr.org/query?id=1024&amp;apiKey=MDAyMDAzMjg3MDEyMjQ1Mjg4OTkxZjcyOQ001</link>
96
+ </parent>
97
+ <parent id="1007" type="topic">
98
+ <title>Health &amp; Science</title>
99
+ <link type="html">http://www.npr.org/templates/topics/topic.php?topicId=1007&amp;ft=3&amp;f=3</link>
100
+ <link type="api">http://api.npr.org/query?id=1007&amp;apiKey=MDAyMDAzMjg3MDEyMjQ1Mjg4OTkxZjcyOQ001</link>
101
+ </parent>
102
+ <parent id="1003" type="topic">
103
+ <title>Nation</title>
104
+ <link type="html">http://www.npr.org/templates/topics/topic.php?topicId=1003&amp;ft=3&amp;f=3</link>
105
+ <link type="api">http://api.npr.org/query?id=1003&amp;apiKey=MDAyMDAzMjg3MDEyMjQ1Mjg4OTkxZjcyOQ001</link>
106
+ </parent>
107
+ <parent id="1001" type="topic">
108
+ <title>News</title>
109
+ <link type="html">http://www.npr.org/templates/topics/topic.php?topicId=1001&amp;ft=3&amp;f=3</link>
110
+ <link type="api">http://api.npr.org/query?id=1001&amp;apiKey=MDAyMDAzMjg3MDEyMjQ1Mjg4OTkxZjcyOQ001</link>
111
+ </parent>
112
+ <audio id="96070747" type="primary">
113
+ <title/>
114
+ <duration>236</duration>
115
+ <format>
116
+ <mp3>http://api.npr.org/m3u/196070747-61f4cc.m3u&amp;ft=3&amp;f=3</mp3>
117
+ <wm>http://www.npr.org/templates/dmg/dmg_wmref_em.php?id=96070747&amp;type=1&amp;mtype=WM&amp;ft=3&amp;f=3</wm>
118
+ <rm>http://www.npr.org/templates/dmg/dmg_rpm.rpm?id=96070747&amp;type=1&amp;mtype=RM&amp;ft=3&amp;f=3</rm>
119
+ </format>
120
+ <rightsHolder/>
121
+ </audio>
122
+ <byline id="96063087">
123
+ <name personId="2100771">Richard Knox</name>
124
+ <link type="html">http://www.npr.org/templates/story/story.php?storyId=2100771&amp;ft=3&amp;f=3</link>
125
+ <link type="api">http://api.npr.org/query?id=2100771&amp;apiKey=MDAyMDAzMjg3MDEyMjQ1Mjg4OTkxZjcyOQ001</link>
126
+ </byline>
127
+ <container id="96063075">
128
+ <title>Related NPR Stories</title><introText/><link refId="96063081" num="1"/><link refId="96063083" num="2"/><link refId="96063085" num="3"/></container>
129
+ <relatedLink id="96063081" type="internal">
130
+ <caption><![CDATA[Study Sheds More Light On 'Placebo Effect']]></caption>
131
+ <link type="html">http://www.npr.org/templates/story/story.php?storyId=87938032&amp;ft=3&amp;f=3</link>
132
+ <link type="api">http://api.npr.org/query?id=87938032&amp;apiKey=MDAyMDAzMjg3MDEyMjQ1Mjg4OTkxZjcyOQ001</link>
133
+ </relatedLink>
134
+ <relatedLink id="96063083" type="internal">
135
+ <caption><![CDATA[Treating Childhood Ouchies With Placebos]]></caption>
136
+ <link type="html">http://www.npr.org/templates/story/story.php?storyId=90864884&amp;ft=3&amp;f=3</link>
137
+ <link type="api">http://api.npr.org/query?id=90864884&amp;apiKey=MDAyMDAzMjg3MDEyMjQ1Mjg4OTkxZjcyOQ001</link>
138
+ </relatedLink>
139
+ <relatedLink id="96063085" type="internal">
140
+ <caption><![CDATA[Depressed? You Don't Need Drugs, Psychiatrist Says]]></caption>
141
+ <link type="html">http://www.npr.org/templates/story/story.php?storyId=92921949&amp;ft=3&amp;f=3</link>
142
+ <link type="api">http://api.npr.org/query?id=92921949&amp;apiKey=MDAyMDAzMjg3MDEyMjQ1Mjg4OTkxZjcyOQ001</link>
143
+ </relatedLink>
144
+ <text>
145
+ <paragraph num="1"><![CDATA[Placebos are common in medical research testing. One group of volunteers gets a test drug, while another group gets a look-alike sugar pill. Everybody is told upfront that they could get one or the other.]]></paragraph>
146
+ <paragraph num="2"><![CDATA[But a new survey finds that many U.S. doctors regularly prescribe placebos even in everyday patient care &mdash; for conditions that haven't responded to treatment, such as chronic pain or fatigue. Patients are almost never aware that they are getting a placebo.]]></paragraph>
147
+ <paragraph num="3"><![CDATA[The idea is that if a patient thinks the pill will help, it just might.]]></paragraph>
148
+ <paragraph num="4"><![CDATA[Of nearly 700 U.S. internal medicine doctors and arthritis specialists surveyed, almost half said they prescribe placebos regularly &mdash; two to three times a month. Only 1 in 20 doctors told patients they were getting a placebo.]]></paragraph>
149
+ <paragraph num="5"><![CDATA[Doctors say they most often will prescribe a vitamin pill or over-the-counter painkiller, though some prescribe an antibiotic or sedative, which the authors of the study say could be harmful. Typically, doctors tell patients the placebo is "potentially helpful, but not designed for your specific illness."]]></paragraph>
150
+ <paragraph num="6"><![CDATA["Half of all American internists and rheumatologists using placebos was a real surprise to me," says Dr. Ezekiel Emanuel, head of ethics at the National Institutes of Health and an author of the study, which appears in the current issue of the British Medical Journal.]]></paragraph>
151
+ <paragraph num="7"><![CDATA[Dr. Howard Brody was surprised, too. Brody, an expert on placebos at the University of Texas in Galveston, says the research shows how much doctors' attitudes have changed over the past few decades.]]></paragraph>
152
+ <paragraph num="8"><![CDATA["For many, many years, the typical reaction of a physician was, 'Well, real doctors don't prescribe placebos. A placebo is a fake medicine. So only a quack would prescribe a placebo,' " says Brody, who was not involved with the survey.]]></paragraph>
153
+ <paragraph num="9"><![CDATA[Since the 1960s, the dominant ethic among U.S. physicians has been "patient autonomy." This means patients are in charge, that they are entitled to know everything about their care, and that a doctor should get informed consent before giving any treatment.]]></paragraph>
154
+ <paragraph num="10"><![CDATA[But if many doctors are handing out placebos, it would be at odds with this ethic, Emanuel says.]]></paragraph>
155
+ <paragraph num="11"><![CDATA["On the one hand, if we have placebos and they work and make people feel good, we're promoting people's health and promoting people's welfare," he says. "But if it requires us to deceive them, we're undermining autonomy."]]></paragraph>
156
+ <paragraph num="12"><![CDATA[The American Medical Association recognizes the predicament. Two years ago, it adopted a policy that the use of a placebo without a patient's knowledge can undermine trust and even result in medical harm.]]></paragraph>
157
+ <paragraph num="13"><![CDATA[Robert Sade, a South Carolina surgeon, was chair of the AMA's ethics council when the new policy was adopted.]]></paragraph>
158
+ <paragraph num="14"><![CDATA["Physicians who use placebos are not being 'unethical,' " Sade says. "But they're skirting on the edges of ethical behavior."]]></paragraph>
159
+ <paragraph num="15"><![CDATA[The AMA says if doctors want to use placebos, they should tell patients that one or more of the pills they're getting is not specifically designed for their illness, but that some have found it helpful. This is basically the definition of a placebo. Studies have shown that placebos sometimes do help people who expect them to work.]]></paragraph>
160
+ <paragraph num="16"><![CDATA[For instance, Sade says, "The physician would tell the patient, 'I'm going to give you these two medications. I want you to take this red pill for a month and record your symptoms. And I want you to take this blue pill for a month and record your symptoms in a log.' "]]></paragraph>
161
+ <paragraph num="17"><![CDATA[It's sort of an experiment involving a single patient. Either or both pills could be placebos.]]></paragraph>
162
+ <paragraph num="18"><![CDATA[But some say this is just a more elaborate kind of deception. "This is not informed consent," says Ted Kaptchuk of Harvard Medical School, who researches the placebo effect. "There's something wrong with the AMA position. I'm not comfortable with it at all."]]></paragraph>
163
+ <paragraph num="19"><![CDATA[Emanuel, the NIH ethics chief, agrees. "I think we're all just a little nervous about that as a common practice," he says. "Even though it might be on the right side of deception, we're not being fully frank with the patient."]]></paragraph>
164
+ <paragraph num="20"><![CDATA[But Emanuel doesn't condemn all placebo use. After all, he says, it shows that American doctors understand that the mind plays a big role in healing, and that's not a bad thing. Copyright 2008 National Public Radio. To see more, visit <a href="http://www.npr.org/">http://www.npr.org/</a>.<img src="http://media.npr.org/images/xanadu.gif?apiKey=MDAyMDAzMjg3MDEyMjQ1Mjg4OTkxZjcyOQ001" />]]></paragraph>
165
+ </text>
166
+ <textWithHtml>
167
+ <paragraph num="1"><![CDATA[Placebos are common in medical research testing. One group of volunteers gets a test drug, while another group gets a look-alike sugar pill. Everybody is told upfront that they could get one or the other.]]></paragraph>
168
+ <paragraph num="2"><![CDATA[But a new survey finds that many U.S. doctors regularly prescribe placebos even in everyday patient care &mdash; for conditions that haven't responded to treatment, such as chronic pain or fatigue. Patients are almost never aware that they are getting a placebo.]]></paragraph>
169
+ <paragraph num="3"><![CDATA[The idea is that if a patient thinks the pill will help, it just might.]]></paragraph>
170
+ <paragraph num="4"><![CDATA[Of nearly 700 U.S. internal medicine doctors and arthritis specialists surveyed, almost half said they prescribe placebos regularly &mdash; two to three times a month. Only 1 in 20 doctors told patients they were getting a placebo.]]></paragraph>
171
+ <paragraph num="5"><![CDATA[Doctors say they most often will prescribe a vitamin pill or over-the-counter painkiller, though some prescribe an antibiotic or sedative, which the authors of the study say could be harmful. Typically, doctors tell patients the placebo is "potentially helpful, but not designed for your specific illness."]]></paragraph>
172
+ <paragraph num="6"><![CDATA["Half of all American internists and rheumatologists using placebos was a real surprise to me," says Dr. Ezekiel Emanuel, head of ethics at the National Institutes of Health and an author of the study, which appears in the current issue of the <em>British Medical Journal.</em>]]></paragraph>
173
+ <paragraph num="7"><![CDATA[Dr. Howard Brody was surprised, too. Brody, an expert on placebos at the University of Texas in Galveston, says the research shows how much doctors' attitudes have changed over the past few decades.]]></paragraph>
174
+ <paragraph num="8"><![CDATA["For many, many years, the typical reaction of a physician was, 'Well, real doctors don't prescribe placebos. A placebo is a fake medicine. So only a quack would prescribe a placebo,' " says Brody, who was not involved with the survey.]]></paragraph>
175
+ <paragraph num="9"><![CDATA[Since the 1960s, the dominant ethic among U.S. physicians has been "patient autonomy." This means patients are in charge, that they are entitled to know everything about their care, and that a doctor should get informed consent before giving any treatment.]]></paragraph>
176
+ <paragraph num="10"><![CDATA[But if many doctors are handing out placebos, it would be at odds with this ethic, Emanuel says.]]></paragraph>
177
+ <paragraph num="11"><![CDATA["On the one hand, if we have placebos and they work and make people feel good, we're promoting people's health and promoting people's welfare," he says. "But if it requires us to deceive them, we're undermining autonomy."]]></paragraph>
178
+ <paragraph num="12"><![CDATA[The American Medical Association recognizes the predicament. Two years ago, it adopted a policy that the use of a placebo without a patient's knowledge can undermine trust and even result in medical harm.]]></paragraph>
179
+ <paragraph num="13"><![CDATA[Robert Sade, a South Carolina surgeon, was chair of the AMA's ethics council when the new policy was adopted.]]></paragraph>
180
+ <paragraph num="14"><![CDATA["Physicians who use placebos are not being 'unethical,' " Sade says. "But they're skirting on the edges of ethical behavior."]]></paragraph>
181
+ <paragraph num="15"><![CDATA[The AMA says if doctors want to use placebos, they should tell patients that one or more of the pills they're getting is not specifically designed for their illness, but that some have found it helpful. This is basically the definition of a placebo. Studies have shown that placebos sometimes do help people who expect them to work.]]></paragraph>
182
+ <paragraph num="16"><![CDATA[For instance, Sade says, "The physician would tell the patient, 'I'm going to give you these two medications. I want you to take this red pill for a month and record your symptoms. And I want you to take this blue pill for a month and record your symptoms in a log.' "]]></paragraph>
183
+ <paragraph num="17"><![CDATA[It's sort of an experiment involving a single patient. Either or both pills could be placebos.]]></paragraph>
184
+ <paragraph num="18"><![CDATA[But some say this is just a more elaborate kind of deception. "This is not informed consent," says Ted Kaptchuk of Harvard Medical School, who researches the placebo effect. "There's something wrong with the AMA position. I'm not comfortable with it at all."]]></paragraph>
185
+ <paragraph num="19"><![CDATA[Emanuel, the NIH ethics chief, agrees. "I think we're all just a little nervous about that as a common practice," he says. "Even though it might be on the right side of deception, we're not being fully frank with the patient."]]></paragraph>
186
+ <paragraph num="20"><![CDATA[But Emanuel doesn't condemn all placebo use. After all, he says, it shows that American doctors understand that the mind plays a big role in healing, and that's not a bad thing. Copyright 2008 National Public Radio. To see more, visit <a href="http://www.npr.org/">http://www.npr.org/</a>.<img src="http://media.npr.org/images/xanadu.gif?apiKey=MDAyMDAzMjg3MDEyMjQ1Mjg4OTkxZjcyOQ001" />]]></paragraph>
187
+ </textWithHtml>
188
+ </story>
189
+ </list>
190
+ </nprml>
@@ -0,0 +1,10 @@
1
+ typical_image: >
2
+ <image id="92343313" type="standard" width="200" src="http://media.npr.org/books/summer/2008/promo_165X40.jpg" hasBorder="false">
3
+ <title>Summer Books Main Page</title>
4
+ <caption/>
5
+ <link url="http://www.npr.org/templates/story/story.php?storyId=90589316">Summer Books Main</link>
6
+ <producer/>
7
+ <provider url=""/>
8
+ <copyright/>
9
+ </image>
10
+
@@ -0,0 +1,15 @@
1
+ item_without_slug: >
2
+ <item id="4499275" num="10" type="column">
3
+ <slug/>
4
+ <title>Sweetness And Light</title>
5
+ <additionalInfo>
6
+ Frank Deford's weekly commentary on sports appears Wednesdays on NPR.org.
7
+ </additionalInfo>
8
+ </item>
9
+
10
+ item_with_slug: >
11
+ <item id="2100140" num="1" type="bio">
12
+ <slug>NPR People</slug>
13
+ <title>Larry Abramson</title>
14
+ <additionalInfo>Education Correspondent, National Desk</additionalInfo>
15
+ </item>