Python'da Mover.uz'dan berilgan havola orqali video'ni yuklab olish usuli:
import requests
import os
class Parse:
"""
kiruvchi havola: https://mover.uz/watch/PUxFuoqm/
chiquvchi video 360: https://v.mover.uz/PUxFuoqm_m.mp4
chiquvchi video 720: https://v.mover.uz/PUxFuoqm_h.mp4
"""
https = 'https://v.mover.uz/'
q_360 = '_m.mp4'
q_720 = '_h.mp4'
q = {
'360': q_360,
'720': q_720
}
user_agent = {'User-agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030529'}
def __init__(self, link):
self.link = link
self.quantity_list = []
self.movie_id = self.link.split('/')[-2] # PUxFuoqm
def search_movies(self):
quantity_360 = self.https + self.movie_id + self.q_360
quantity_720 = self.https + self.movie_id + self.q_720
self.processing_quantity(quantity_360, '360')
self.processing_quantity(quantity_720, '720')
return self.quantity_list
def processing_quantity(self, quantity, text):
res360 = requests.get(quantity, headers=self.user_agent)
if res360.status_code == 200:
self.quantity_list.append(text)
def uploads(self, list_uploads):
self.create_folder()
quantity = {
'360': self.https + self.movie_id + self.q_360,
'720': self.https + self.movie_id + self.q_720
}
for up in list_uploads:
res = requests.get(quantity[up], headers=self.user_agent)
with open(f"{os.getcwd()}/uploads/{up}_{quantity[up].split('/')[-1]}", 'wb') as f:
f.write(res.content)
return True
@staticmethod
def create_folder():
base_dir = os.getcwd()
list_dir = os.listdir(base_dir)
if 'uploads' not in list_dir:
try:
os.mkdir('uploads')
except OSError:
raise Exception("Uploads katalogini yaratib bo'lmadi, ruxsatni tekshiring")
if __name__ == "__main__":
parser = Parse('https://mover.uz/watch/PUxFuoqm/')
parser.uploads(parser.search_movies())
Rahmat: @alimanuz
@uzpythonlogs
#parsing #mover #videohavola #yuklabolish
import requests
import os
class Parse:
"""
kiruvchi havola: https://mover.uz/watch/PUxFuoqm/
chiquvchi video 360: https://v.mover.uz/PUxFuoqm_m.mp4
chiquvchi video 720: https://v.mover.uz/PUxFuoqm_h.mp4
"""
https = 'https://v.mover.uz/'
q_360 = '_m.mp4'
q_720 = '_h.mp4'
q = {
'360': q_360,
'720': q_720
}
user_agent = {'User-agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030529'}
def __init__(self, link):
self.link = link
self.quantity_list = []
self.movie_id = self.link.split('/')[-2] # PUxFuoqm
def search_movies(self):
quantity_360 = self.https + self.movie_id + self.q_360
quantity_720 = self.https + self.movie_id + self.q_720
self.processing_quantity(quantity_360, '360')
self.processing_quantity(quantity_720, '720')
return self.quantity_list
def processing_quantity(self, quantity, text):
res360 = requests.get(quantity, headers=self.user_agent)
if res360.status_code == 200:
self.quantity_list.append(text)
def uploads(self, list_uploads):
self.create_folder()
quantity = {
'360': self.https + self.movie_id + self.q_360,
'720': self.https + self.movie_id + self.q_720
}
for up in list_uploads:
res = requests.get(quantity[up], headers=self.user_agent)
with open(f"{os.getcwd()}/uploads/{up}_{quantity[up].split('/')[-1]}", 'wb') as f:
f.write(res.content)
return True
@staticmethod
def create_folder():
base_dir = os.getcwd()
list_dir = os.listdir(base_dir)
if 'uploads' not in list_dir:
try:
os.mkdir('uploads')
except OSError:
raise Exception("Uploads katalogini yaratib bo'lmadi, ruxsatni tekshiring")
if __name__ == "__main__":
parser = Parse('https://mover.uz/watch/PUxFuoqm/')
parser.uploads(parser.search_movies())
Rahmat: @alimanuz
@uzpythonlogs
#parsing #mover #videohavola #yuklabolish