CineMax commited on
Commit
4e54e7e
·
verified ·
1 Parent(s): 82f3097

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -10
app.py CHANGED
@@ -633,8 +633,10 @@ def process_bulk(
633
 
634
  git_dir = str(output_dir)
635
  subprocess.run(['git', 'init'], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
 
636
  subprocess.run(['git', 'remote', 'add', 'origin', repo_git_url], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
637
- subprocess.run(['git', 'config', 'http.postBuffer', '524288000'], cwd=git_dir, check=True)
 
638
 
639
  files = os.listdir(git_dir)
640
 
@@ -645,21 +647,59 @@ def process_bulk(
645
  seg_files = [f for f in files if f.endswith('.ts')]
646
  manifest_files = [f for f in files if f.endswith('.m3u8')]
647
 
648
- subprocess.run(['git', 'add'] + manifest_files, cwd=git_dir, check=True)
 
649
  subprocess.run(['git', 'commit', '-m', 'Add manifests'], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
650
 
651
- try:
652
- subprocess.run(['git', 'push', '-u', 'origin', 'main'], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=600)
653
- except:
654
- subprocess.run(['git', 'push', '-f', 'origin', 'HEAD:main'], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=600)
655
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
656
  batch_size = int(batch_size_vid)
657
 
 
 
 
658
  for i in range(0, len(seg_files), batch_size):
659
  batch = seg_files[i:i+batch_size]
660
- subprocess.run(['git', 'add'] + batch, cwd=git_dir, check=True)
661
- subprocess.run(['git', 'commit', '-m', f'Batch {i}'], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
662
- subprocess.run(['git', 'push', 'origin', 'main'], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=600)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
663
  progress((idx + (i/len(seg_files))) / total_sources)
664
 
665
  gooplay_link = f'https://gooplay.xyz/gp/stream.php?repo={repo_name}&branch=main&file={manifest_file}'
 
633
 
634
  git_dir = str(output_dir)
635
  subprocess.run(['git', 'init'], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
636
+ subprocess.run(['git', 'checkout', '-b', 'main'], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
637
  subprocess.run(['git', 'remote', 'add', 'origin', repo_git_url], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
638
+ subprocess.run(['git', 'config', 'http.postBuffer', '524288000'], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
639
+ subprocess.run(['git', 'config', 'core.compression', '0'], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
640
 
641
  files = os.listdir(git_dir)
642
 
 
647
  seg_files = [f for f in files if f.endswith('.ts')]
648
  manifest_files = [f for f in files if f.endswith('.m3u8')]
649
 
650
+ # Commit inicial con manifests
651
+ subprocess.run(['git', 'add'] + manifest_files, cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
652
  subprocess.run(['git', 'commit', '-m', 'Add manifests'], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
653
 
654
+ # Primer push creando la rama main
655
+ msg, logs = log_generator(" 📤 Push inicial...", logs)
656
+ yield msg, logs, ""
657
+
658
+ retry_count = 0
659
+ while retry_count < 3:
660
+ try:
661
+ subprocess.run(['git', 'push', '-u', 'origin', 'main'], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, timeout=600)
662
+ break
663
+ except subprocess.CalledProcessError as e:
664
+ retry_count += 1
665
+ if retry_count >= 3:
666
+ # Si ya existe el repo, forzar push
667
+ try:
668
+ subprocess.run(['git', 'push', '-f', 'origin', 'main'], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, timeout=600)
669
+ break
670
+ except Exception as e2:
671
+ raise Exception(f"Error push inicial: {str(e2)}")
672
+ except subprocess.TimeoutExpired:
673
+ retry_count += 1
674
+ if retry_count >= 3:
675
+ raise Exception("Timeout en push inicial")
676
+
677
+ # Subir segmentos en batches
678
  batch_size = int(batch_size_vid)
679
 
680
+ msg, logs = log_generator(f" 📦 Subiendo {len(seg_files)} segmentos (batch: {batch_size})...", logs)
681
+ yield msg, logs, ""
682
+
683
  for i in range(0, len(seg_files), batch_size):
684
  batch = seg_files[i:i+batch_size]
685
+ subprocess.run(['git', 'add'] + batch, cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
686
+ subprocess.run(['git', 'commit', '-m', f'Batch {i}-{i+len(batch)}'], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
687
+
688
+ # Push con reintentos
689
+ retry_count = 0
690
+ while retry_count < 3:
691
+ try:
692
+ subprocess.run(['git', 'push', 'origin', 'main'], cwd=git_dir, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, timeout=600)
693
+ break
694
+ except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as e:
695
+ retry_count += 1
696
+ if retry_count >= 3:
697
+ msg, logs = log_generator(f" ⚠️ Error en batch {i}, continuando...", logs)
698
+ yield msg, logs, ""
699
+ break
700
+ msg, logs = log_generator(f" 🔄 Reintento {retry_count}/3 batch {i}...", logs)
701
+ yield msg, logs, ""
702
+
703
  progress((idx + (i/len(seg_files))) / total_sources)
704
 
705
  gooplay_link = f'https://gooplay.xyz/gp/stream.php?repo={repo_name}&branch=main&file={manifest_file}'