Skip to content

Commit

Permalink
feat(bindings): firefox based
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Sep 30, 2023
1 parent e49c6ac commit 288a86c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion bindings/python/rookiepy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
"edge",
"chrome",
"chromium_based",
"firefox_based"
"to_dict",
"to_cookiejar",
"create_cookie"
"create_cookie",
]

def create_cookie(host, path, secure, expires, name, value, http_only):
Expand Down
17 changes: 12 additions & 5 deletions bindings/python/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

use std::{fmt::{self}, time::SystemTime, path::PathBuf};
use rookie::{self, enums::{CookieToString,Cookie}};
use pyo3::types::{PyFloat, PyString, PyList, PyDict};
use pyo3::exceptions::{PyTypeError, PyKeyError};
use std::{time::SystemTime, path::PathBuf};
use rookie::{self,Cookie};

use pyo3::prelude::*;

Expand All @@ -14,7 +12,6 @@ pub struct PyCookie {
}



#[pymethods]
impl PyCookie {
#[getter]
Expand Down Expand Up @@ -112,12 +109,22 @@ fn chromium_based(_py: Python, key_path: String, db_path: String, domains: Optio
Ok(py_cookies)
}

#[pyfunction]
fn firefox_based(_py: Python, db_path: String, domains: Option<Vec<&str>>) -> PyResult<Vec<PyCookie>> {
let cookies = rookie::firefox_based(PathBuf::from(db_path), domains).unwrap();

let py_cookies: Vec<PyCookie> = cookies.into_iter().map(|cookie| PyCookie { inner: cookie }).collect();

Ok(py_cookies)
}

#[pymodule]
fn rookiepy(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(firefox, m)?)?;
m.add_function(wrap_pyfunction!(chrome, m)?)?;
m.add_function(wrap_pyfunction!(brave, m)?)?;
m.add_function(wrap_pyfunction!(edge, m)?)?;
m.add_function(wrap_pyfunction!(chromium_based, m)?)?;
m.add_function(wrap_pyfunction!(firefox_based, m)?)?;
Ok(())
}

0 comments on commit 288a86c

Please sign in to comment.