EchterAlsFake / EPorner_API

a Python API for Eporner.com
GNU Lesser General Public License v3.0
4 stars 2 forks source link

An error occurred: Invalid URL 'fSv0S5alPY2': No scheme supplied. Perhaps you meant https://fsv0s5alpy2/ #1

Closed yourmomlover closed 7 months ago

yourmomlover commented 7 months ago

from eporner_api.eporner_api import Client, Quality, Order, Gay, LowQuality, Encoding

Add other commands as needed

sent_eporner_links = set()

@client.command(name='eporner_search') async def eporner_search(ctx, query, num_links: int = 1): eporner_client = Client() # Create the client without enable_html_scraping

try:
    sorting_order = Order.latest
    sorting_gay = Gay.exclude_gay_content
    sorting_low_quality = LowQuality.exclude_low_quality_content
    page = 1
    per_page = 10

    videos = []  # Define 'videos' before the loop

    for attempt in range(3):
        try:
            videos = eporner_client.search_videos(query=query, sorting_order=sorting_order,
                                                  sorting_gay=sorting_gay, sorting_low_quality=sorting_low_quality,
                                                  page=page, per_page=per_page, enable_html_scraping=True)
            break
        except Exception as e:
            print(f"Error in attempt {attempt + 1}: {e}")
            await asyncio.sleep(2)

    for _ in range(num_links):
        for video in videos:
            video_title = video.title if hasattr(video, 'title') and video.title else 'No Title'
            quality = Quality.BEST
            mode = Encoding.mp4_h264  # Use recommended encoding

            # Check if the video object has a valid URL
            if hasattr(video, 'source_url') and video.source_url:
                source_url = video.source_url
                if not source_url.startswith(('http://', 'https://')):
                    source_url = f'https://{source_url}'  # Add 'https://' if missing

                # Use direct_download_link on the video object
                best_quality_url = video.direct_download_link(quality=quality, mode=mode, enable_html_scraping=True)

                if best_quality_url:
                    if best_quality_url not in sent_eporner_links:
                        embed = nextcord.Embed(title=f"Eporner Video: {video_title}", description=f"Download link: {best_quality_url}")
                        await ctx.send(embed=embed)

                        sent_eporner_links.add(best_quality_url)

                        await nextcord.sleep(1)
                        break
                else:
                    print(f"Invalid direct download link for video: {video_title}")
            else:
                print(f"Video object does not have a valid source URL: {video_title}")

except Exception as e:
    await ctx.send(f"An error occurred: {e}")     **`code for a discordbot`**
EchterAlsFake commented 7 months ago

Hi, thanks for your Issue.

Is the codeblock you shared for a Discord Bot? And I don't understand where exactly the issue happened.

You are talking about the "No scheme supplied" I guess.

But at which point does that occur? I can't read it from your script and I didn't find this issue.

While you've written this I actually worked a lot on EPorner, so maybe you uninstall the library and reinstall it from my GitHub.

You can do this by doing:

pip install git+https://github.com/EchterAlsFake/EPorner_API

yourmomlover commented 7 months ago

yeah its for a discord bot using the nextcord library , i think the issue is related to the response url as this is fSv0S5alPY2 probably the unique identifier for the vid that is used in the url but the url format isn't right is my best guess , ill try the repo ig

EchterAlsFake commented 7 months ago

Yes, try the repo and let me know :)

yourmomlover commented 7 months ago

i tried many ways , im pretty sure the link it returns is broken as it only sends the unique video code like fSv0S5alPY2 instead of a full link like https://www.eporner.com/video-KdvrY24MSrc/too-cute-for-porn/ in this link u can see the unique code it provides KdvrY24MSrc , i tried to hardcode it to convert this into the actual link by getting the title and along with the url and formatting it but it dosent work , and yes i did install the git repo

EchterAlsFake commented 7 months ago

Okay I'll look into it.

EchterAlsFake commented 7 months ago

Should be fixed now. The issue was, that I was extracting the ID instead of the URL from the json response. I don't know why I did this lol.

yourmomlover commented 7 months ago

sheesh works nicely and btw the video.download() spelling is wrong in the docs , just letting u know lmao

EchterAlsFake commented 7 months ago

Okay thanks xD