File size: 1,364 Bytes
0191c63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
class MotionMuseIntegration extends HTMLElement {
  constructor() {
    super();
    this.apiKey = 'free_tier_key'; // Replace with actual free tier key
    this.baseUrl = 'https://api.motionmuse.ai/v1';
  }

  async generateAnimation(imageData, options = {}) {
    try {
      const response = await fetch(`${this.baseUrl}/animate`, {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'Authorization': `Bearer ${this.apiKey}`
        },
        body: JSON.stringify({
          image: imageData,
          duration: options.duration || 10,
          style: options.style || 'realistic',
          music: options.music || false,
          nsfw: true
        })
      });

      if (!response.ok) {
        throw new Error('Animation generation failed');
      }

      return await response.json();
    } catch (error) {
      console.error('MotionMuse API error:', error);
      throw error;
    }
  }

  async getStatus(jobId) {
    try {
      const response = await fetch(`${this.baseUrl}/status/${jobId}`, {
        headers: {
          'Authorization': `Bearer ${this.apiKey}`
        }
      });
      return await response.json();
    } catch (error) {
      console.error('Status check error:', error);
      throw error;
    }
  }
}

customElements.define('motionmuse-integration', MotionMuseIntegration);