Skip to content

Commit

Permalink
Merge pull request otwcode#561 from elzj/ffnet_import_message
Browse files Browse the repository at this point in the history
Adding messages to make it clear why ff.net imports aren't working
  • Loading branch information
neuroalien committed Mar 31, 2012
2 parents a675d3f + 10f4e4d commit 0370a4d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
41 changes: 21 additions & 20 deletions app/models/story_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -442,26 +442,27 @@ def download_from_lj(location)

# grab all the chapters of the story from ff.net
def download_chaptered_from_ffnet(location)
raise Error, "We cannot read #{location}. Are you trying to import from the story preview?" if location.match(/story_preview/)
raise Error, "The url #{location} is locked." if location.match(/secure/)
@chapter_contents = []
if location.match(/^(.*fanfiction\.net\/s\/[0-9]+\/)([0-9]+)(\/.*)$/i)
urlstart = $1
urlend = $3
chapnum = 1
Timeout::timeout(STORY_DOWNLOAD_TIMEOUT) {
loop do
url = "#{urlstart}#{chapnum.to_s}#{urlend}"
body = download_with_timeout(url)
if body.nil? || chapnum > MAX_CHAPTER_COUNT || body.match(/FanFiction\.Net Message/)
break
end
@chapter_contents << body
chapnum = chapnum + 1
end
}
end
return @chapter_contents
raise Error, "Imports from fanfiction.net are no longer available due to a block on their end. :("
# raise Error, "We cannot read #{location}. Are you trying to import from the story preview?" if location.match(/story_preview/)
# raise Error, "The url #{location} is locked." if location.match(/secure/)
# @chapter_contents = []
# if location.match(/^(.*fanfiction\.net\/s\/[0-9]+\/)([0-9]+)(\/.*)$/i)
# urlstart = $1
# urlend = $3
# chapnum = 1
# Timeout::timeout(STORY_DOWNLOAD_TIMEOUT) {
# loop do
# url = "#{urlstart}#{chapnum.to_s}#{urlend}"
# body = download_with_timeout(url)
# if body.nil? || chapnum > MAX_CHAPTER_COUNT || body.match(/FanFiction\.Net Message/)
# break
# end
# @chapter_contents << body
# chapnum = chapnum + 1
# end
# }
# end
# return @chapter_contents
end


Expand Down
12 changes: 7 additions & 5 deletions app/views/works/new_import.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<!--Descriptive page name, messages and instructions-->
<h2 class="heading"><%= ts("Import New Work") %> <%= link_to_help 'work-import'%></h2>
<%= error_messages_for :work %>
<div class="notice">
<p class="important">
<strong><%= ts("Please note!") %></strong>
<%= ts("This doesn't always work. If you have trouble, ") %>
<div class="notice">
<p class="important">
<%= ts("Please note! Imports from fanfiction.net are no longer available because of a block on their end.") %>
</p>
<p>
<%= ts("If you have trouble importing from another site, ") %>
<%= link_to ts("please let us know"), new_feedback_report_path %>
<%= ts("so we can improve this tool!") %>
</p>
</p>
<p>You might find the <a href="http://archiveofourown.org/archive_faqs/9">Import <abbr title="frequently asked questions">FAQ</abbr></a> useful.</p>
</div>

Expand Down

0 comments on commit 0370a4d

Please sign in to comment.