Skip to content

Commit

Permalink
rem
Browse files Browse the repository at this point in the history
  • Loading branch information
krypton-byte committed Aug 16, 2022
1 parent 06306c7 commit a236e77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions examples/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ async def on_progress(self, binaries: bytes):
print(f'Download: %s ' % ((int(self.clength/self.length * 100)).__str__() + '%'), end='\r')
async def on_finish(self, client: httpx.AsyncClient, response: httpx.Response):
self.io.seek(0)

async def main(url):
vid = await Fb().from_url(url)
print(vid)
dd = Download(await vid[1].get_size())
await vid[1].download(dd)
open('video.mp4','wb').write(dd.io.getvalue())

asyncio.run(main(url)) #type: ignore
9 changes: 7 additions & 2 deletions snapsave/snapsave.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
def translate(text: str) -> bool:
return text.lower() in ['iya', 'yes']


class Regex:
URL_FILTER = re.compile(r'(https?://[\w+&=\.%\-_/?;]+)')
ORIGIN_URL = re.compile(r'https?://[\w\.-]+/')
Expand All @@ -23,6 +22,7 @@ class Regex:
FROM_SNAPAPP = re.compile(r'^https?://snapsave\.app')
QUALITY = re.compile(r'"video-quality">(\d+|Audio|HD|SD)')
DECODER_ARGS = re.compile(r'\(\".*?,.*?,.*?,.*?,.*?.*?\)')
COVER = re.compile(r'<img src=[\\]?"([\w://\.\=&?-]+)')


def sorted_video(videos: list[FacebookVideo]) -> list[FacebookVideo]:
Expand Down Expand Up @@ -157,6 +157,11 @@ def __repr__(self) -> str:
return f'{self.quality.value}::render={self.render}' + ('::'+[
'SD', 'HD'][self.is_hd] if self.is_hd or self.is_sd else '')

class Videos(list):
def __init__(self, cover: str):
super().__init__()
self.cover = cover


class Fb(AsyncClient):

Expand Down Expand Up @@ -190,7 +195,7 @@ async def from_url(self, url: str) -> list[FacebookVideo]:
return await self.extract_content(dec)

async def extract_content(self, src: str) -> list[FacebookVideo]:
data = []
data = Videos(Regex.COVER.findall(src)[0])
n = Regex.TABLE.findall(src)[0].replace('\\"', '"')
for url, res, render in zip(
Regex.URL_FILTER.findall(n),
Expand Down

0 comments on commit a236e77

Please sign in to comment.