Struct WebshareProxyConfig

Source
pub struct WebshareProxyConfig {
    pub proxy_username: String,
    pub proxy_password: String,
    pub domain_name: String,
    pub proxy_port: u16,
    pub retries: i32,
}
Expand description

§WebshareProxyConfig

Specialized proxy configuration for Webshare’s rotating residential proxies.

Webshare provides residential proxies that rotate IPs automatically, which is extremely useful for accessing YouTube without being blocked. This configuration is optimized for Webshare’s API format.

§Features

  • Automatic IP rotation for each request
  • Configurable retry mechanism for handling blocks
  • Optimized for Webshare’s proxy service

§Important Note

For reliable YouTube access, use Webshare’s “Residential” proxies, not the “Proxy Server” or “Static Residential” options, as YouTube often blocks those IPs.

§Example Usage

// Create a Webshare proxy configuration with credentials
let proxy = WebshareProxyConfig::new(
    "your_username".to_string(),
    "your_password".to_string(),
    5,                             // Retry up to 5 times if blocked
    None,                          // Use default domain
    None                           // Use default port
);

// Use it with the YouTube Transcript API
let api = YouTubeTranscriptApi::new(
    None,
    Some(Box::new(proxy)),
    None
)?;

Fields§

§proxy_username: String

Your Webshare proxy username

§proxy_password: String

Your Webshare proxy password

§domain_name: String

The proxy domain name (default: “p.webshare.io”)

§proxy_port: u16

The port number to use (default: 80)

§retries: i32

Number of retries to attempt when blocked

Implementations§

Source§

impl WebshareProxyConfig

Source

pub const DEFAULT_DOMAIN_NAME: &'static str = "p.webshare.io"

Default domain name for Webshare proxies

Source

pub const DEFAULT_PORT: u16 = 80u16

Default port for Webshare proxies

Source

pub fn new( proxy_username: String, proxy_password: String, retries_when_blocked: i32, domain_name: Option<String>, proxy_port: Option<u16>, ) -> Self

Creates a new Webshare proxy configuration.

This configuration is specifically designed for Webshare’s rotating proxy service. It automatically adds the rotation feature to your proxy.

§Parameters
  • proxy_username - Your Webshare proxy username
  • proxy_password - Your Webshare proxy password
  • retries_when_blocked - Number of retries to attempt if blocked (recommended: 3-5)
  • domain_name - Optional custom domain name (default: “p.webshare.io”)
  • proxy_port - Optional custom port (default: 80)
§Returns
  • Self - A new Webshare proxy configuration
§Example
// Basic configuration
let proxy = WebshareProxyConfig::new(
    "username".to_string(),
    "password".to_string(),
    3,     // Retry 3 times
    None,  // Use default domain
    None   // Use default port
);

// Custom domain and port
let proxy_custom = WebshareProxyConfig::new(
    "username".to_string(),
    "password".to_string(),
    5,
    Some("custom.webshare.io".to_string()),
    Some(8080)
);
Source

pub fn url(&self) -> String

Generates the complete proxy URL for Webshare.

This formats the proxy URL with rotation enabled by appending “-rotate” to the username, which tells Webshare to provide a new IP for each request.

§Returns
  • String - The formatted proxy URL
§Example (internal)
let proxy = WebshareProxyConfig::new(
    "user123".to_string(),
    "pass456".to_string(),
    3,
    None,
    None
);

// Generates: "http://user123-rotate:pass456@p.webshare.io:80/"
let url = proxy.url();

Trait Implementations§

Source§

impl Clone for WebshareProxyConfig

Source§

fn clone(&self) -> WebshareProxyConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WebshareProxyConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ProxyConfig for WebshareProxyConfig

Source§

fn to_requests_dict(&self) -> HashMap<String, String>

Converts the Webshare proxy configuration to a reqwest-compatible dictionary.

Uses the same URL for both HTTP and HTTPS requests.

§Returns
  • HashMap<String, String> - Map with “http” and “https” keys and proxy URLs
Source§

fn prevent_keeping_connections_alive(&self) -> bool

Always returns true to ensure connection rotation.

Webshare rotating proxies work best when a new connection is established for each request, ensuring you get a fresh IP address each time.

§Returns
  • bool - Always true for Webshare proxies
Source§

fn retries_when_blocked(&self) -> i32

Returns the configured number of retries.

This determines how many times the library will retry a request with a new IP address if YouTube blocks the request.

§Returns
  • i32 - The number of retries to attempt
Source§

fn as_any(&self) -> &dyn Any

Type conversion for dynamic dispatch and type identification. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T