avinashprajapati commited on
Commit
56cce3e
·
verified ·
1 Parent(s): b52eb04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -16
app.py CHANGED
@@ -383,8 +383,8 @@ def analyze_video(video_path, video_name):
383
 
384
 
385
  # ==================== COMPACT PDF GENERATION (SINGLE PAGE) ====================
386
- def extract_name_mobile(filename):
387
- """Extract name and mobile from video filename"""
388
  try:
389
  # Remove extension
390
  name_without_ext = os.path.splitext(filename)[0]
@@ -394,23 +394,18 @@ def extract_name_mobile(filename):
394
 
395
  if len(parts) >= 3:
396
  name = parts[0].title() # Avinash
397
- mobile = parts[1] # 7845474854
398
- #email = parts[2]
399
- return name, mobile #, email
400
  elif len(parts) == 2:
401
  name = parts[0].title()
402
  mobile = parts[1] if parts[1].isdigit() and len(parts[1]) == 10 else "Not Provided"
403
- return name, mobile
404
  else:
405
- return filename, "Not Provided"
406
 
407
  except:
408
- return filename, "Not Provided"
409
-
410
-
411
-
412
-
413
-
414
 
415
  # ==================== SINGLE PAGE A4 PDF GENERATION ====================
416
  def create_pdf_report(report, filename):
@@ -437,8 +432,8 @@ def create_pdf_report(report, filename):
437
  DARK_TEXT = colors.HexColor('#1F2937')
438
  LIGHT_TEXT = colors.HexColor('#6B7280')
439
 
440
- # Extract name and mobile
441
- candidate_name, mobile_number = extract_name_mobile(report['video_name'])
442
 
443
  # Ultra Compact Styles
444
  title_style = ParagraphStyle(
@@ -496,7 +491,8 @@ def create_pdf_report(report, filename):
496
  # ===== COMPACT CANDIDATE INFO =====
497
  candidate_data = [
498
  ['👤 Candidate:', candidate_name, '📱 Mobile:', mobile_number],
499
- ['🎥 Video:', report['video_name'][:25] + '...' if len(report['video_name']) > 25 else report['video_name'], '⏱️ Duration:', f"{report['duration_seconds']:.1f}s"],
 
500
  ]
501
 
502
  candidate_table = Table(candidate_data, colWidths=[1.2*inch, 2.2*inch, 1.2*inch, 2.2*inch])
@@ -506,6 +502,7 @@ def create_pdf_report(report, filename):
506
  ('BOTTOMPADDING', (0, 0), (-1, -1), 6),
507
  ('TOPPADDING', (0, 0), (-1, -1), 6),
508
  ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
 
509
  ]))
510
  story.append(candidate_table)
511
  story.append(Spacer(1, 0.1*inch))
 
383
 
384
 
385
  # ==================== COMPACT PDF GENERATION (SINGLE PAGE) ====================
386
+ def extract_name_mobile_email(filename):
387
+ """Extract name, mobile and email from video filename"""
388
  try:
389
  # Remove extension
390
  name_without_ext = os.path.splitext(filename)[0]
 
394
 
395
  if len(parts) >= 3:
396
  name = parts[0].title() # Avinash
397
+ mobile = parts[1] # 8235263572
398
+ email = parts[2] # avinashprajapati9199@gmail.com
399
+ return name, mobile, email
400
  elif len(parts) == 2:
401
  name = parts[0].title()
402
  mobile = parts[1] if parts[1].isdigit() and len(parts[1]) == 10 else "Not Provided"
403
+ return name, mobile, "Not Provided"
404
  else:
405
+ return filename, "Not Provided", "Not Provided"
406
 
407
  except:
408
+ return filename, "Not Provided", "Not Provided"
 
 
 
 
 
409
 
410
  # ==================== SINGLE PAGE A4 PDF GENERATION ====================
411
  def create_pdf_report(report, filename):
 
432
  DARK_TEXT = colors.HexColor('#1F2937')
433
  LIGHT_TEXT = colors.HexColor('#6B7280')
434
 
435
+ # Extract name, mobile and email
436
+ candidate_name, mobile_number, email_id = extract_name_mobile_email(report['video_name'])
437
 
438
  # Ultra Compact Styles
439
  title_style = ParagraphStyle(
 
491
  # ===== COMPACT CANDIDATE INFO =====
492
  candidate_data = [
493
  ['👤 Candidate:', candidate_name, '📱 Mobile:', mobile_number],
494
+ ['📧 Email:', email_id, '⏱️ Duration:', f"{report['duration_seconds']:.1f}s"],
495
+ ['🎥 Video:', report['video_name'][:25] + '...' if len(report['video_name']) > 25 else report['video_name'], '', ''],
496
  ]
497
 
498
  candidate_table = Table(candidate_data, colWidths=[1.2*inch, 2.2*inch, 1.2*inch, 2.2*inch])
 
502
  ('BOTTOMPADDING', (0, 0), (-1, -1), 6),
503
  ('TOPPADDING', (0, 0), (-1, -1), 6),
504
  ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
505
+ ('SPAN', (2, 2), (3, 2)), # Span the last row for video name
506
  ]))
507
  story.append(candidate_table)
508
  story.append(Spacer(1, 0.1*inch))