lazysdk 0.1.3__tar.gz → 0.1.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {lazysdk-0.1.3 → lazysdk-0.1.5}/PKG-INFO +1 -1
  2. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazym3u8.py +100 -0
  3. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk.egg-info/PKG-INFO +1 -1
  4. {lazysdk-0.1.3 → lazysdk-0.1.5}/setup.py +1 -1
  5. {lazysdk-0.1.3 → lazysdk-0.1.5}/README.md +0 -0
  6. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/__init__.py +0 -0
  7. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazyCrypto.py +0 -0
  8. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazybase64.py +0 -0
  9. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazydict.py +0 -0
  10. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazyenv.py +0 -0
  11. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazyexcel.py +0 -0
  12. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazyfile.py +0 -0
  13. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazyflask.py +0 -0
  14. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazyid.py +0 -0
  15. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazyip.py +0 -0
  16. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazymd5.py +0 -0
  17. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazypath.py +0 -0
  18. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazyprocess.py +0 -0
  19. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazyproxies.py +0 -0
  20. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazyrandom.py +0 -0
  21. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazyredis.py +0 -0
  22. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazyrequests.py +0 -0
  23. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazytext.py +0 -0
  24. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazytime.py +0 -0
  25. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazyua.py +0 -0
  26. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk/lazywebhook.py +0 -0
  27. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk.egg-info/SOURCES.txt +0 -0
  28. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk.egg-info/dependency_links.txt +0 -0
  29. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk.egg-info/requires.txt +0 -0
  30. {lazysdk-0.1.3 → lazysdk-0.1.5}/lazysdk.egg-info/top_level.txt +0 -0
  31. {lazysdk-0.1.3 → lazysdk-0.1.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lazysdk
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: 基于Python的懒人包
5
5
  Home-page: https://gitee.com/ZeroSeeker/lazysdk
6
6
  Author: ZeroSeeker
@@ -5,6 +5,7 @@ from . import lazytime
5
5
  from . import lazyfile
6
6
  from . import lazypath
7
7
  from . import lazymd5
8
+ from . import lazyprocess
8
9
  import subprocess
9
10
  import threading
10
11
  import requests
@@ -503,6 +504,105 @@ def download_fragment(
503
504
  return download_res
504
505
 
505
506
 
507
+ def download_fragment_single(
508
+ task_index,
509
+ task_info,
510
+ ):
511
+ """
512
+ 模块功能:下载单个碎片到指定文件夹
513
+ :param fragment_url: 碎片下载地址
514
+ :param fragment_url_name: 碎片名
515
+ :param fragment_path:碎片保存路径
516
+ :param aes_key: aes解密key
517
+ :param headers:请求头
518
+ :param fragment_suffix:碎片文件后缀名
519
+ :return:
520
+ """
521
+ fragment_url = task_info['fragment_url']
522
+ fragment_url_name = task_info['fragment_url_name']
523
+ fragment_path = task_info['fragment_path']
524
+ aes_key = None,
525
+ headers = None,
526
+ fragment_suffix = task_info['fragment_suffix']
527
+
528
+ if headers is None:
529
+ headers_local = default_headers
530
+ else:
531
+ headers_local = headers
532
+
533
+ print('正在下载', fragment_url_name, fragment_url)
534
+ fragment_file_name = '%s%s%s.%s' % (fragment_path, path_separator, fragment_url_name, fragment_suffix) # 生成碎片文件名
535
+ # 开始下载碎片文件
536
+ while True:
537
+ try:
538
+ with open(fragment_file_name, "ab+") as f:
539
+ response = requests.get(
540
+ url=fragment_url,
541
+ headers=headers_local,
542
+ stream=True,
543
+ timeout=timeout
544
+ )
545
+ total_length = response.headers.get('content-length')
546
+
547
+ if total_length is None:
548
+ print("Attention: There is no content length in header!") # 未返回长度信息
549
+ else:
550
+ dl = 0
551
+ total_length = int(total_length)
552
+ for data in track(
553
+ sequence=response.iter_content(chunk_size=8192),
554
+ description='下载中',
555
+ total=total_length/8192,
556
+ show_speed=True
557
+ ):
558
+ dl += len(data)
559
+ if aes_key is None:
560
+ data_decode = data
561
+ else:
562
+ data_decode = lazyCrypto.aes_decode(data, aes_key)
563
+ f.write(data_decode)
564
+ f.flush()
565
+ break
566
+ except:
567
+ showlog.warning('下载超时,将在1秒后重试...')
568
+ os.remove(fragment_file_name)
569
+ time.sleep(1)
570
+ pass
571
+
572
+
573
+ def download_fragment_quick(
574
+ url_list,
575
+ subprocess_limit=None
576
+ ):
577
+ fragment_path = 'fragment_%s' % str(time.time()).replace('.', '') # 使用时间戳命名
578
+ fragment_suffix = 'ts'
579
+ lazypath.make_path(fragment_path)
580
+ task_list = list()
581
+ fragment_file_name_list = list()
582
+ for url_index, each_url in enumerate(url_list):
583
+ task_list.append(
584
+ {
585
+ 'fragment_url': each_url,
586
+ 'fragment_url_name': url_index,
587
+ 'fragment_path': fragment_path,
588
+ 'fragment_suffix': fragment_suffix
589
+ }
590
+ )
591
+ fragment_file_name = '%s%s%s.%s' % (fragment_path, path_separator, url_index, fragment_suffix) # 生成碎片文件名
592
+ fragment_file_name_list.append(fragment_file_name)
593
+ lazyprocess.run(
594
+ task_list=task_list,
595
+ task_function=download_fragment_single,
596
+ subprocess_limit=subprocess_limit
597
+ )
598
+ download_res = {
599
+ 'fragment_path': fragment_path,
600
+ 'fragment_suffix': fragment_suffix,
601
+ 'fragment_file_name_list': fragment_file_name_list
602
+ }
603
+ return download_res
604
+
605
+
506
606
  def download_m3u8(
507
607
  m3u8_link=None,
508
608
  m3u8_file_path=None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lazysdk
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: 基于Python的懒人包
5
5
  Home-page: https://gitee.com/ZeroSeeker/lazysdk
6
6
  Author: ZeroSeeker
@@ -13,7 +13,7 @@ with open("README.md", "r", encoding='utf-8') as fh:
13
13
 
14
14
  setuptools.setup(
15
15
  name="lazysdk",
16
- version="0.1.3",
16
+ version="0.1.5",
17
17
  description="基于Python的懒人包",
18
18
  long_description=long_description,
19
19
  long_description_content_type="text/markdown",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes