aboutsummaryrefslogtreecommitdiff
path: root/src/bibiman.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bibiman.rs')
-rw-r--r--src/bibiman.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/bibiman.rs b/src/bibiman.rs
index 754e8f6..0c0d99b 100644
--- a/src/bibiman.rs
+++ b/src/bibiman.rs
@@ -24,7 +24,6 @@ use crate::tui::Tui;
use crate::{bibiman::entries::EntryTable, bibiman::keywords::TagList};
use arboard::Clipboard;
use color_eyre::eyre::Result;
-use doi2bib;
use editor_command::EditorBuilder;
use futures::executor::block_on;
use ratatui::widgets::ScrollbarState;
@@ -129,12 +128,22 @@ impl Bibiman {
///
///The method needs two arguments: the CLIArgs struct and the `str` containing the DOI
pub fn handle_new_entry_submission(&mut self, args: &CLIArgs, doi_string: &str) {
- let doi2bib = doi2bib::Doi2Bib::new().unwrap();
- let new_entry_future = doi2bib.resolve_doi(doi_string);
- let new_entry = block_on(new_entry_future);
+ let doi_string = if doi_string.starts_with("10.") {
+ "https://doi.org/".to_string() + doi_string
+ } else {
+ doi_string.to_owned()
+ };
+
+ // Send GET request to doi resolver
+ let doi_entry = ureq::get(&doi_string)
+ .set("Accept", "application/x-bibtex")
+ .call();
- if let Ok(entry) = new_entry {
+ if let Ok(entry) = doi_entry {
// Save generated bibtex entry in structs field
+ let entry = entry
+ .into_string()
+ .expect("Couldn't parse fetched entry into string");
self.popup_area.popup_sel_item = entry;
self.popup_area.popup_kind = Some(PopupKind::AppendToFile);
self.append_to_file(args);